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

clientSchemaDirectives is not working for apollo:codegen since 2.18.0 #1484

Open
adrienharnay opened this issue Aug 23, 2019 · 5 comments
Open

Comments

@adrienharnay
Copy link
Contributor

Hello,

I have a mutation:

mutation mutate($arg: String!) {
  mutate @MyCustomDirective(arg: $arg) {
    id
  }
}

And I'm trying to run apollo:codegen with this config:

module.exports = {
  client: {
    service: {
      name: 'name',
      url: 'url',
      includes: [`${__dirname}/packages/**/*.gql`],
      headers: {
        Authorization:
          'Bearer token',
      },
    },
    clientSchemaDirectives: [
      'client',
      'rest',
      'MyCustomDirective',
    ],
  },
};

Intended outcome:

Codegen should come through.

Actual outcome:

yarn apollo:codegen

Loading Apollo Project
Generating query files
.../mutate.gql: Unknown directive "MyCustomDirective".

How to reproduce the issue:

Add a custom directive to one of your .gql files, add it to clientSchemaDirectives, and run apollo:codegen.

Versions

apollo@2.18.0

With 2.17.4, it was working without having to specify

    clientSchemaDirectives: [
      'client',
      'rest',
      'MyCustomDirective',
    ],

Thanks in advance!

@codybrouwers
Copy link

I was running into this issue with the @rest directive and I managed to fix it by manually defining the directive in my client side schema.graphql file like so:

directive @rest(
  type: String!
  path: String!
  method: String
  endpoint: String
  bodyKey: String = "input"
) on FIELD

@slorber
Copy link

slorber commented Feb 13, 2020

Also have this issue. I don't want to modify local schema because it's downloaded automatically from server.

Hack is to append the directive to downloaded schema during the automated process, which is not optimal but works:

"apollo:downloadSchema:local": "graphql get-schema -e local && yarn apollo:downloadSchema:addLocalDirectivesHack",
"apollo:downloadSchema:addLocalDirectivesHack": "cat localDirectivesHack.graphql.txt >> schema.graphql",

@evankennedy
Copy link

evankennedy commented Feb 25, 2020

I get the same issue as @codybrouwers with @rest. I have defined the directive in my local schema file to get around one error, but I get this other error that the @client directive is missing:
Screenshot from 2020-02-24 23-36-45

I have not added clientOnlyDirectives or clientSchemaDirectives in my apollo config, but it doesn't work even if I add the default.

@guiccbr
Copy link

guiccbr commented Apr 22, 2020

@evankennedy , the same is happening to me, and I wasn't able to fix. Does anyone know if there's a way of fixing this?

@dvelitchkov
Copy link

Just to add to the pile, looks like apollo's own code generator doesn't recognize apollo's own federation directives:

Unknown directive "key".
Unknown directive "external".

There's no reason why I'd have to supply anything external to make apollo's own tool work with their own schema/server and federation spec.

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

No branches or pull requests

6 participants