Search code examples
graphqlgraphql-jsprisma

Is there any way of importing Query with a custom directive applied?


I want to import Mutation.updateUser() from "./generated/prisma.graphql", but I also want to add the @isAdmin directive. I can accomplish this by copying the query by hand:

type Mutation {
  updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User @isAdmin
}

But that means I have to copy every query/mutation/type I want to add a directive to, is there any sintax like this?

# import Mutation.updateUser from "./generated/prisma.graphql" @isAdmin

Solution

  • Unfortunately this is not possible at the moment. GraphQL SDL by default has no way of importing types or fields of types (as you want to do) into other files.

    Based on the # import ...-syntax you show, I believe you're trying to use graphql-import. With this library it's possible to import entire types but not individual fields of types. If you'd like to have that functionality in the graphql-import library, please open an issue.