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
I have a shared entity between two subgraphs, to keep things simple I'll call them the List service and the Item service.
Items can be retrieved in 3 ways:
Items may appear as a collection of Items under a List (a federated entity between the List and Item services)
They may be queried for against the Item service using some filters (Query definition: items(filter: ItemsFilter!):ItemPage)
They may be queried for directly against the Item service if the ID is known (Query definition: item(id:ID!): Item)
I've set these up using the directive @key(fields: "id") and everything works as expected.
The requests to resolve large lists of items was a performance concern as each item was being resolved with a single request to the Item service, so in order to reduce this to a single call I introduced the @entityResolver(multi: true) directive to the entity definition in the Item service. This worked fine for the federated calls and only a single request was being made to resolve multiple Item IDs (scenario 1).
However in scenario 2 and 3 I'm now getting a Failed to query 'items': directive entityResolver is not implemented and a Failed to query 'item': directive entityResolver is not implemented error message for the corresponding queries.
From debugging the generated code, it seems that for scenario 2 the correct item filter resolver is called and returns the data, it then tries to resolve the fields and throws the error. For scenario 3, the item by id resolver is never called and the error is thrown.
What did you expect?
I expected the queries in scenarios 2 and 3 above to continue working after the @entityResolver(multi: true) directive was introduced.
Minimal graphql.schema and models to reproduce
If the resolvers are generated for the following, the single resolver query will work as expected, the multi resolver query will show the issue.
type RegularEntity @key(fields: "id") {
id: ID!
Name: String!
}
type RegularEntityWrapper {
id: ID!
Name: String!
Entity: RegularEntity!
}
type MultiResolverEntity @key(fields: "id") @entityResolver(multi: true) {
id: ID!
Name: String!
}
type MultiResolverEntityWrapper {
id: ID!
Name: String!
Entity: MultiResolverEntity!
}
type Query {
singleResolver: RegularEntityWrapper
multiResolver: MultiResolverEntityWrapper
}
versions
gqlgen v0.17.45
go1.22.2 darwin/arm64
The text was updated successfully, but these errors were encountered:
What happened?
I have a shared entity between two subgraphs, to keep things simple I'll call them the List service and the Item service.
Items can be retrieved in 3 ways:
items(filter: ItemsFilter!):ItemPage
)item(id:ID!): Item
)I've set these up using the directive
@key(fields: "id")
and everything works as expected.The requests to resolve large lists of items was a performance concern as each item was being resolved with a single request to the Item service, so in order to reduce this to a single call I introduced the
@entityResolver(multi: true)
directive to the entity definition in the Item service. This worked fine for the federated calls and only a single request was being made to resolve multiple Item IDs (scenario 1).However in scenario 2 and 3 I'm now getting a
Failed to query 'items': directive entityResolver is not implemented
and aFailed to query 'item': directive entityResolver is not implemented
error message for the corresponding queries.From debugging the generated code, it seems that for scenario 2 the correct item filter resolver is called and returns the data, it then tries to resolve the fields and throws the error. For scenario 3, the item by id resolver is never called and the error is thrown.
What did you expect?
I expected the queries in scenarios 2 and 3 above to continue working after the
@entityResolver(multi: true)
directive was introduced.Minimal graphql.schema and models to reproduce
If the resolvers are generated for the following, the single resolver query will work as expected, the multi resolver query will show the issue.
versions
The text was updated successfully, but these errors were encountered: