Add a graphQL fragment to the schema and have it accessible to all queries

The following is done correctly in the schedule

fragment BookGridFields on Book { _id title } { allBooks { ...BookGridFields } } 

My question is, can I specify a fragment directly in my scheme, right below where my type of book is defined, for example

 type Book { _id: String title: String pages: Int weight: Float authors: [Author] } fragment BookGridFields on Book { _id title } 

So I can just run queries like this

 { allBooks { ...BookGridFields } } 

without having to define a fragment as part of my request.

Currently the above errors with

Unknown fragment \ "BookGridFields \"

+7
javascript graphql graphql-js
source share

No one has answered this question yet.

See related questions:

1011
How to remove all parameters of a selection window and then add one parameter and select it using jQuery?
6
How to use names in GraphQLEnumType as default value for GraphQL query argument?
4
Given the set of types of GraphQL variables, is it possible to use a client schema to create a map of all valid values ​​for each type in the set
3
Getting started in graphql-php: how to add resolver functions to a schema from a .graphql file?
2
GraphQL - passing an object of non-specific objects as an argument
2
How to test GraphQL queries using fragments using jokes
one
How to Convert GraphQLSchema Object Definitions to Type
one
AWS appsync w / Lambd backend, GraphQL gives unexpected repsonce for query
0
How to define an object field in GraphQLObjectType?

All Articles