Server GraphQL file reference
The server GraphQL schema file is generated by the nitrogql generate
command and written to the path specified by the generate.serverGraphqlOutput
option.
This file is useful for server-side code where you need to supply a GraphQL schema to a GraphQL server.
This file contains your entire GraphQL schema as a string. In addition, as it is made a TypeScript file which exports schema
, you do not need to do file system access by yourself. With this file, passing your schema to a server is as simple as:
import { schema } from "./generated/serverGraphql";
import { Resolvers } from "./generated/resolvers";
import { ApolloServer } from "apollo-server";
const resolvers: Resolvers<{}> = { /* ... */ };
const server = new ApolloServer({
typeDefs: schema,
resolvers,
});