Replies: 1 comment 1 reply
-
If you want to do simple arguments with int you can use schema.intArg(), anything like an object you're going to have to use schema.arg() and deal with actual input types. Docs aren't great but here they are. https://nexus.js.org/docs/api-args Please note inputObjectType and objectType are different, and in the GraphQL spec inputs are treated differently to objects, check out your generated SDL some time and take a look at all the args you've been defined. Also i suggest researching a bit on inputs and args, e.g. https://graphql.org/graphql-js/mutations-and-input-types/ Something like this should work:
|
Beta Was this translation helpful? Give feedback.
-
I need to pass an array as an argument.
[ {id: 1} , {id: 2} ]
This is the first time the argument I'm passing is not a scalar value. But I cannot figure out how to do it. I'm assuming it's objectType, but I really don't know what from there.
I want to pass the above array as 'items'.
In the field below, typescript throws the following error:
Expected 1 arguments, but got 0.ts(2554) stateful-nexus-schema.d.ts(36, 47): An argument for 'config' was not provided.
Obviously I could give the object a name, but then it wants a description with fields per the docs for objectType. And I honestly have no idea how to describe an array...If I could even just override the typechecking requirement in this one instance, I'd be happy enough with that honestly! Usually I massage the data on the client side so as to make sure just strings, enums, booleans and ints come through to the server, but I can't do that in this case... Is there any way I could just escape out of this schema requirement?
Any help is greatly, greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions