Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directive disappears when an enum has resolvers defined #1148

Closed
kamilkisiela opened this issue Jun 12, 2019 · 3 comments
Closed

Directive disappears when an enum has resolvers defined #1148

kamilkisiela opened this issue Jun 12, 2019 · 3 comments

Comments

@kamilkisiela
Copy link
Collaborator

Using the following typeDefs with makeExecutableSchema should result in a GraphQLSchema that contains @auth directive but it fails when we define resolvers for an enum.

/**
 * directive that uses enum
 */
const typeDefs = `
  directive @auth(role: Role!) on FIELD | FIELD_DEFINITION

  enum Role {
    ADMIN
    USER
  }

  type Query {
    foo: String @auth(role: ADMIN)
  }
`;

Works

/**
 * Produced GraphQLSchema has @auth directive
 */
const schema = makeExecutableSchema({
  typeDefs,
});

console.log(schema.getDirective('auth')) // outputs: auth

Doesn't work

/**
 * Produced GraphQLSchema has no @auth directive, because enum has resolvers
 */
const schema = makeExecutableSchema({
  typeDefs,
  resolvers: {
    Role: {
      ADMIN: 'A',
      USER: 'U'
    }
  }
});

console.log(schema.getDirective('auth')) // outputs: undefined

Repro: https://stackblitz.com/edit/typescript-ktnvjs?file=index.ts

@yaacovCR
Copy link
Collaborator

yaacovCR commented Oct 4, 2019

Fixed in graphql-tools-fork, https://www.npmjs.com/package/graphql-tools-fork

@JForsaken
Copy link

Do we have an ETA on when the graphql-tools-fork fix for this will be merged into graphql-tools? 🙏

@yaacovCR
Copy link
Collaborator

Rolled into #1306

@yaacovCR yaacovCR mentioned this issue Mar 29, 2020
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants