compile-schema v0.1.0
Compile-Schema
Apollo GraphQL Targetted Schema Management
Function Exports
compileSchema(folder='./schema/',saveSchema=true, plugin=[])
folder
The folder that your schema files are primarily located in. GraphQL files will be stored in this folder.
saveSchema
Determines whether or not the system compiles the GraphQL files into a single file. schema.graphql
plugin
Experimental Functionality: Supports any function that accepts a single string parameters and returns a string parameter.
compileExecutableSchema(folder='./schema/',exec=function() {},saveSchema=true, plugin=[]
folder
The folder that your schema files are primarily located in. GraphQL files will be stored in this folder.
exec
Wrap your {resolvers, typeDefs}
inside of a function before exporting the result.
saveSchema
Determines whether or not the system compiles the GraphQL files into a single file. schema.graphql
plugin
Experimental Functionality: Supports any function that accepts a single string parameters and returns a string parameter.
Internal functions
compileGraphQl(saveSchema,folder='./schema/',resolver_dir="", plugin=[],typescript=false)
Generates the graphql type definitions object
compileSchema
const { ApolloServer } = require('apollo-server');
const { compileSchema } = require('compile-schema');
const resolvers = require('./resolvers');
let schemaFolder = "./type/";
const typeDefs = compileSchema(schemaFolder);
// The ApolloServer constructor requires two parameters: your schema
// definition and your set of resolvers.
const server = new ApolloServer({ typeDefs, resolvers });
// The `listen` method launches a web server.
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
compileTypescriptSchema
const { ApolloServer } = require('apollo-server');
const { compileTypescriptSchema } = require('../');
const resolvers = require('./resolvers');
let schemaFolder = "./type/";
const typeDefs = compileTypescriptSchema(schemaFolder);
// The ApolloServer constructor requires two parameters: your schema
// definition and your set of resolvers.
const server = new ApolloServer({ typeDefs, resolvers });
// The `listen` method launches a web server.
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
Schema Folder Structure