Skip to content

Commit 1c44b59

Browse files
committed
Remove Node interface from Query
1 parent 30a0bff commit 1c44b59

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = function RemoveNodeInterfaceFromQueryPlugin(builder) {
2+
builder.hook("GraphQLObjectType:interfaces", (interfaces, build, context) => {
3+
if (!context.scope.isRootQuery) {
4+
return interfaces;
5+
}
6+
return [];
7+
});
8+
builder.hook("GraphQLObjectType", (obj, build, context) => {
9+
if (!context.scope.isRootQuery) {
10+
return obj;
11+
}
12+
const { isTypeOf, ...rest } = obj;
13+
return rest;
14+
});
15+
};

lib/createSchema.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const graphileBuild = requireFrom(
2525
);
2626

2727
const RenamedQueryPlugin = require("./RenamedQueryPlugin");
28+
const RemoveNodeInterfaceFromQueryPlugin = require("./RemoveNodeInterfaceFromQueryPlugin");
2829

2930
const skipPlugins = [
3031
graphileBuild.QueryPlugin,
@@ -33,6 +34,8 @@ const skipPlugins = [
3334
];
3435
const prependPlugins = [RenamedQueryPlugin];
3536

37+
const appendPlugins = [RemoveNodeInterfaceFromQueryPlugin];
38+
3639
module.exports = async (pool, schema, options) => {
3740
const schemas = Array.isArray(schema) ? schema : schema.split(",");
3841
const graphqlSchema = await createPostGraphileSchema(pool, schemas, {
@@ -44,6 +47,7 @@ module.exports = async (pool, schema, options) => {
4447
...options,
4548
skipPlugins: [...skipPlugins, ...(options.skipPlugins || [])],
4649
prependPlugins: [...prependPlugins, ...(options.prependPlugins || [])],
50+
appendPlugins: [...appendPlugins, ...(options.appendPlugins || [])],
4751
});
4852
return graphqlSchema;
4953
};

0 commit comments

Comments
 (0)