Skip to content
Advertisement

How to create an array in the GraphQL’s argumment as GraphQL Code First Approach

In GraphQL Code First Approach I am trying to pass the same argumment for createUser in createManyUser but I want to pass it as an array to create many users at once. I searched a lot but couldn’t find it in GraphQL Code First Approach.

enter image description here

The Code

JavaScript

Advertisement

Answer

You can’t just put the args options in an array, to tell GraphQL that you expect a list of things you explicitly need to construct a GraphQLList type.

And you can’t make a mutation field take a list of named things either – you must give the mutation one named argument that expects a list of input objects. So it’ll be

JavaScript

See also this article.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement