You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there!
I am using Apollo Federation in order to make references to types of other Services. I have a Project Service that offers several Project Types (SoftwareDevelopmentProject, MarketingProject etc) that implement a Project interface. Then I have a Service for the Access rights, where I basically just try to reference the Projects from the project Service by their ID. Due to #336 my current approach is to try using the concrete types (not the interface) to make references to the other Service. Unfortunately I cannot get the Project Service / Gateway to finally resolve the references.
My schema in the Projects Service looks like this:
And the Rights service with the types using extend and @key looks like this:
type Query {
user: User
}
type User {
id: String!
name: String!
accessibleProjects: [Project]
}
extend interface Project {
id: ID! @external
}
extend type SoftwareDevelopmentProject implements Project @key(fields: "id") {
id: ID! @external
}
extend type MarketingProject implements Project @key(fields: "id") {
id: ID! @external
}
I did an analysis and the Apollo Gateway seems to request the Access-Rights Service for all Project IDs and then performs a Request to the Project Service. This request looks like:
What I would expect is that the representations Array is filled with the IDs and typenames of the Projects.
Also I noticed the ...on Project in the request, which is the interface, not the implementing types (even though __resolveType was called previously in the access rights Service), however this is might be not a real problem as I think it could be handled by the Projects Service.
The text was updated successfully, but these errors were encountered:
I have the same issue - need to reference interface or union from one service to another. Seems that it's not supported from Apollo Federation as per their docs : An entity's @key cannot include fields that hold unions or interfaces.link and sounds reasonable to me for union types, because they don't contain any fields where to put @key directive which consist primary key, but seems possible idea to be supported for interfaces. Thoughts ?
Also to resolve interface Project from the second service you need to provide __resolveReference and __resolveType in the typed Project resolver , no ?
abernix
transferred this issue from apollographql/apollo-server
Jan 15, 2021
Same problem here.
I have an elastic search service that returns an array of Metadata Interfaces (id, type, ....) and a Dgraph service that holds the Metadata implementations.
Had to create an UNION type in the elasticsearch Apollo server using all the implementation of the Metadata.
I still can't figure out if it is my Apollo Federation's design to be wrong, or if it is Apollo Federation to be not production ready.
Version: @apollo/[email protected]
Reproduction: https://github.com/mmuth/apollo-federation-interface-referencing
Related to: #336
Hi there!
I am using Apollo Federation in order to make references to types of other Services. I have a Project Service that offers several Project Types (
SoftwareDevelopmentProject
,MarketingProject
etc) that implement aProject
interface. Then I have a Service for the Access rights, where I basically just try to reference the Projects from the project Service by their ID. Due to #336 my current approach is to try using the concrete types (not the interface) to make references to the other Service. Unfortunately I cannot get the Project Service / Gateway to finally resolve the references.My schema in the Projects Service looks like this:
And the Rights service with the types using
extend
and@key
looks like this:I did an analysis and the Apollo Gateway seems to request the Access-Rights Service for all Project IDs and then performs a Request to the Project Service. This request looks like:
What I would expect is that the representations Array is filled with the IDs and typenames of the Projects.
Also I noticed the
...on Project
in the request, which is the interface, not the implementing types (even though__resolveType
was called previously in the access rights Service), however this is might be not a real problem as I think it could be handled by the Projects Service.The text was updated successfully, but these errors were encountered: