The graphile-build module

We export two methods, both of which take the same arguments:

  • plugins - an array of plugin functions to execute
  • options - an optional hash of options to pass through to all the plugins

We also export one property: 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));


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) {
  await builder.watchSchema(onSchema);}