Need help or advice? We now offer Development Support, direct from the maintainer Get support
The graphile-build module
We export two methods, both of which take the same arguments:
plugins
- an array of plugin functions to executeoptions
- an optional hash of options to pass through to all the plugins
We also export one property: defaultPlugins
defaultPlugins
An array of the built-in plugins, see Default Plugins for more info.
buildSchema(plugins, options)
Returns a promise which resolves to a GraphQL schema generated from the list of plugins provided.
const { buildSchema, defaultPlugins } = require("graphile-build");
const { printSchema } = require("graphql/utilities");
async function main() {
const schema = await buildSchema(defaultPlugins); console.log(printSchema(schema));
}
main();
getBuilder(plugins, options)
Loads all the plugins and returns an instance of SchemaBuilder
. This is useful
if you want to use watch mode; see
SchemaBuilder
for more information.
const { getBuilder, defaultPlugins } = require("graphile-build");
async function main() {
const builder = await getBuilder(defaultPlugins, {}); function onSchema(schema) {
console.log(printSchema(schema));
}
await builder.watchSchema(onSchema);}
main();