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

Issues with Redefinition and missing @key #1

Open
dougogodinho opened this issue Feb 18, 2020 · 1 comment
Open

Issues with Redefinition and missing @key #1

dougogodinho opened this issue Feb 18, 2020 · 1 comment

Comments

@dougogodinho
Copy link

dougogodinho commented Feb 18, 2020

Hey friend, thanks for sharing your code...
Im having the folowing issue:

Directive "external" already exists in the schema. It cannot be redefined.
Directive "requires" already exists in the schema. It cannot be redefined.
Directive "provides" already exists in the schema. It cannot be redefined.
Directive "key" already exists in the schema. It cannot be redefined.
Directive "extends" already exists in the schema. It cannot be redefined.

Any idea?

@angry-dan
Copy link

Yep. I'm getting that too.

Here's a quick workaround that's working for me...

  1. Add the following to your schema:
type Query {
  … other stuff in your query root here
  _service: _Service!
}

type _Service {
  sdl: String
}
  1. Remove your call to $federation->extendSchema but leave the one for addResolversToRootValue

Explanation:
The Apollo docs are a bit unclear on this, but the _service query is meant to return your service definition without additional directives declared:

This SDL does not include the additions of the federation spec above.

The extendSchema function adds all that stuff to the schema (which is correct), but then the resolver for _service returns the full schema unmodified, so Apollo gets upset that you didn't strip that stuff out before generating the SDL

I'll get a PR together if I have time.

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

2 participants