graphile-build
Version:
Build a GraphQL schema from plugins
38 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StreamDeferPlugin = void 0;
require("graphile-config");
/**
* Enables stream/defer on the schema.
*
* Removing this plugin will result in a GraphQL schema that does not enable
* stream/defer.
*/
exports.StreamDeferPlugin = {
name: "StreamDeferPlugin",
version: "1.0.0",
description: `Enables stream and defer on the schema`,
schema: {
hooks: {
GraphQLSchema: {
callback: (schema, build) => {
const { GraphQLStreamDirective, GraphQLDeferDirective, graphqlHasStreamDefer, } = build.grafast;
const { specifiedDirectives } = build.graphql;
if (graphqlHasStreamDefer) {
// @ts-ignore
schema.enableDeferStream = true;
}
else {
schema.directives = [
...(schema.directives ?? specifiedDirectives),
GraphQLStreamDirective,
GraphQLDeferDirective,
];
}
return schema;
},
},
},
},
};
//# sourceMappingURL=StreamDeferPlugin.js.map