graphql-mesh: `prefix` transform with `includeRootOperations: true` breaks for `postgraphile` handler

I guess it’s because postgraphile does some stuff to Query type and uses interfaces on it.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

I think it’s valid for a root type to have interfaces, though? This sounds like potentially a bug in RenameRootTypes?

UPDATE: please see https://github.com/graphile/gatsby-source-pg/blob/master/lib/RemoveNodeInterfaceFromQueryPlugin.js for a maintained plugin; the below isn’t as thorough as it could be.


I think this’ll work (typed straight into the textbox, so may need a subtle tweak here and there):

export default function StripQueryInterfacePlugin(builder) {
  builder.hook('GraphQLObjectType:interfaces', (interfaces, build, context) => {
    const {
      scope: { isRootQuery },
    } = context;
    if (!isRootQuery) {
      return interfaces;
    }

    // Strip all interfaces from `Query`
    return [];
  });
}

It’s basically the reverse of this: https://github.com/graphile/graphile-engine/blob/9dca5c8631e6c336b59c499d901c774d41825c60/packages/graphile-build/src/plugins/NodePlugin.js#L166-L188

I fixed it using @benjie 's example, worked like a charm 😉

I can write you a small plugin to remove the interface from Query if you like.