1

This is a fragment of a JSON object I receive from an http response. enter image description here

How does one code the corresponding "networks" field in the GraphQLObjectType? here is the associated (and working!) definition. enter image description here

I appreciate any and all help. I am new to GraphQL, but tried to solve the question myself. The answer was elusive, as all the examples I came across had to do with lists that referenced other nodes of the graph.

1 Answer 1

2

The GraphQLList wrapper can be used to indicate arrays of objects (GraphQLObjectType) or scalars like GraphQLString, GraphQLInt, GraphQLBoolean, etc. That means you can just do:

networks: { type: new GraphQLList(GraphQLString) }

Note that unlike declaring a normal type or scalar, when using GraphQLList (or GraphQLNonNull) you have to call its constructor using the new keyword.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.