[Feature Request] Apollo Federation Support
See original GitHub issueApollo Federation makes uses of some custom directives:
https://www.apollographql.com/docs/apollo-server/federation/federation-spec/
Version and Environment Details
Operation system: macOS
IDE name and version: IntelliJ IDEA Ultimate 2019.2
Plugin version: 2.2.0
Expected Behaviour
-
The following directives should not produce errors:
directive @external on FIELD_DEFINITION directive @requires(fields: _FieldSet!) on FIELD_DEFINITION directive @provides(fields: _FieldSet!) on FIELD_DEFINITION directive @key(fields: _FieldSet!) on OBJECT | INTERFACE directive @extends on OBJECT | INTERFACE
(These directives must NOT be in the GraphQL file itself)
-
An
extend type TypeName
should be allowed to exist without the base type, as the base type may be defined by another service
Actual Behaviour
- Error:
Unknown directive "XXX"
- Error:
The extension 'TypeName' type [@x:x] is missing its base underlying type
Steps to Reproduce / Link to Repo with Reproduction and Instructions
type InternalType @key(fields: "id") {
id: ID!
xyz: String!
externalObject: ExternalType @requires(fields: "xyz") @provides(fields: "foo")
}
# In reality you need EITHER extend OR @extends
# depending on which server this schema is defined in
# (Apollo Server allows extend, graphql-java requires @extends)
extend type ExternalType @key(fields: "id") @extends {
id: ID! @external
foo: String! @external
bar: String! @external
baz: String!
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:6
Top Results From Across the Web
Introduction to Apollo Federation - Apollo GraphQL Docs
Federation supports a free managed mode with Apollo GraphOS, which helps you ... clients can fetch data from all of your subgraphs with...
Read more >Feature Request: Support Apollo Graphql Federation #492
We use hundreds of microservices, and a monolithic GraphQL server becomes an unacceptable development bottleneck and single point of failure, so it becomes ......
Read more >Apollo Federation compatibility - Feature Requests
Apollo says: To be part of a federated graph, an implementing service must conform to the Apollo Federation specification, which exposes the ...
Read more >Apollo Federation – GraphQL Yoga
Please note that Apollo Federation implementation doesn't support ... const { parse } = require('graphql') const { buildSubgraphSchema } ...
Read more >Apollo Federation
Implementing services are now known as subgraphs. If you find an outdated use of "implementing service," please submit article feedback or a pull...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking at the examples of how to configure and extend the plugin (https://github.com/jimkyndemeyer/graphql-config-examples) perhaps a boilerplate example for Apollo Federation would help people get started.
Hi Nihal.
Thanks for using the plugin.
Like you mention, these directives are custom, and the plugin only ships with the directives that are described in the GraphQL spec. This is intentional, as new GraphQL frameworks appear all the time. For this reason you have to declare framework directives yourself, and ensure that they’re picked up as part of schema discovery. You can look at an example at https://github.com/jimkyndemeyer/graphql-config-examples/tree/master/extend-client-fields-and-directives which shows how to work with the
@client
Apollo directive.Extending non-existing types violates the GraphQL Spec https://graphql.github.io/graphql-spec/June2018/#sec-Object-Extensions validation “The named type must already be defined and must be an Object type.” As such,
graphql-java
which this plugin is based on works correctly, so I’m not sure how we would go about adding support for this. Potentially the validation needs to be configurable as it makes sense to enforce it for other use cases.I noted one interesting comment in your code example:
If you declared your directives as expected, and used
@extends
I believe the plugin would work as is.Best regards, Jim