Example of recursion GraphQL query and schema

node v7.10.1
version: 1.0.0
endpointsharetweet
var { graphql, GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLInterfaceType, buildSchema, } = require('graphql'); var hero = new GraphQLObjectType({ name: 'hero', fields: () => ({ name: { type: GraphQLString, }, hero: { type: hero, } }), }); var query = new GraphQLObjectType({ name: 'query', fields: { hero: { type: hero, }, }, }); var schema = new GraphQLSchema({ query: query, }); var resolvers = {}; resolvers.hero = { name: () => 'abc', }; resolvers.hero.hero = resolvers.hero; await graphql(schema, ` { hero { name hero { name hero { name hero { name } } } } } `, resolvers).then()
Loading…

no comments

    sign in to comment