Hi,
I am implementing a federated service and have added the federation schema specs found here. Apollo Federation subgraph specification - Apollo GraphQL Docs
scalar _Any
scalar _FieldSet
# a union of all types that use the @key directive
union _Entity
type _Service {
sdl: String
}
extend type Query {
_entities(representations: [_Any!]!): [_Entity]!
_service: _Service!
}
directive @external on FIELD_DEFINITION
directive @requires(fields: _FieldSet!) on FIELD_DEFINITION
directive @provides(fields: _FieldSet!) on FIELD_DEFINITION
directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE
# this is an optional directive discussed below
directive @extends on OBJECT | INTERFACE
Now I am having trouble implementing (or resolving) the _entities field on the query root. In other words, I am unsure how best to resolve the _entities Query method,
_entities(representations: [_Any!]!): [_Entity]!
.
I have not been able to find examples of how the _entities
Query can be implemented to successfully query a federated service. Any advice would be appreciated. Thanks in advance.
I am using @graphql-tools
to add resolvers to schema and need to define _entities
Query:
const resolvers = {
Query: {
libraries() {
return libraries;
},
_service() {
return service;
},
// _entities() {}
},
Thanks in advance.