Plugin Options
The second argument to
buildSchema and getBuilder
is an options object with arbitrary properties which is made available to
every plugin as its second argument.
Supported Options​
The following options apply to the default plugins:
nodeIdFieldName- defaults toidwhich might clash with your other fields. It is not recommended to change it, but you might considernodeIdinstead. (Use of__idis discouraged because GraphQL wants to deprecate non-introspection fields that begin with__)
Plugins may expect further options if they wish, for example see
those of graphile-build-pg. To prevent
collisions between the property names, the plugins should follow some
namespacing conventions.
Example​
The following example passes the nodeIdFieldName setting through, changing
from the default id to flibble:
const { buildSchema, defaultPlugins } = require("graphile-build");
const { printSchema } = require("graphql/utilities");
buildSchema(defaultPlugins, { nodeIdFieldName: "flibble" }).then((schema) => {
console.log(printSchema(schema));
});
which modifies the Node interface thusly:
interface Node {
# A globally unique identifier. Can be used in various places throughout the system to identify this single value.
flibble: ID!
}