I put the GraphQL shell on top of the outgoing REST API, as described in Zero to GraphQL in 30 minutes . I have an API endpoint for a product with one property that points to a nested object:
Is it possible to define a schema so that I can get all this nested object without explicitly defining the nested object and all its properties? I want my query to simply indicate that I want a nested object, and I do not need to specify all the properties that I want from a nested object:
I can make the second version, but it requires a lot of additional code, including creating NestedObjectType and specifying all attached properties. I also figured out how to automatically get a list of all keys, for example:
const ProductType = new GraphQLObjectType({ ... fields: () => ({ nestedObject: { type: new GraphQLList(GraphQLString), resolve: product => Object.keys(product.nested_object) } }) })
I did not understand the way to automatically return the entire object.
graphql
collinksmith
source share