Introspection

The description property, which can be defined on many GraphQL schema elements, is used to give clients some details about an object. When clients read the schema information, the description of each object will be available to them.

For example, GraphQL shows the description value for a field object in the type-ahead dropdown that lists fields available inside a selection set. To see that in action, let's give our example schema fields some description. In schema/main.js, modify the queryType object as follows:

const queryType = new GraphQLObjectType({ name: 'RootQuery', fields: { hello: { type: GraphQLString, resolve: () => 'world' }, diceRoll: { description: '**Simulate** a dice roll determined by count', type: new GraphQLList(GraphQLInt), ...

Get Learning GraphQL and Relay now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.