One of the powerful points of GraphQL is that GraphQL Schema can be used to describe all the APIs on the server side.
We can use the printSchema
function from the graphql
package to print out the Schema.
The above code generates a schema.graphql
file that contains all the contents of the Schema.
GraphQL Schema can be used for many purposes, common uses include:
Merging Schema from multiple microservices into a supergraph for unified cross-service querying on the client side. This architecture is called federation.
Developed and type-checked on the client side using code generation.
Integrate with TypeScript for client-side development for better type checking and auto-completion during development, see gql.tada for more information.