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
Component and Resource are both entities that extend the Entity interface, and they both have a field spec.type which is used to drill down to more specific entity types via @discriminates.
In my catalog I have a Resource that is described with spec.type: service, which causes an error to occur when querying the graphql endpoint:
{
"errors": [
{
"message": "Unexpected error.",
"locations": [
{
"line": 4,
"column": 7
}
],
"path": [
"entities",
"edges",
1,
"node"
],
"extensions": {
"originalError": {
"message": "Can't resolve type for node with \"Node@Catalog@{\"ref\":\"resource:digital/live-feeder-db\"}\" id. The \"Service\" type which was discriminated by Resource interface does not implement the \"Resource\" interface",
"stack": "Error: Can't resolve type for node with \"Node@Catalog@{\"ref\":\"resource:digital/live-feeder-db\"}\" id. The \"Service\" type which was discriminated by Resource interface does not implement the \"Resource\" interface\n at GraphQLInterfaceType.resolveType (/workspaces/backstage/backstage/node_modules/@frontside/hydraphql/src/mapInterfaceType.ts:242:19)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /workspaces/backstage/backstage/node_modules/@graphql-tools/executor/cjs/execution/promiseForObject.js:18:35\n at async Promise.all (index 0)"
}
}
}
],
"data": {
"entities": null
}
}
In the backend logs:
2024-10-27T23:58:42.545Z graphql error Can't resolve type for node with "Node@Catalog@{"ref":"resource:digital/live-feeder-db"}" id. The "Service" type which was discriminated by Resource interface does not implement the "Resource" interface
GraphQL request:4:7
3 | edges {
4 | node {
| ^
5 | kind
I can resolve the error by updating the schema to this:
It looks like the request is matching the @discriminate function on Entity to map the entity to a Resource, but then when Resource discriminates the spec.type field, it is reading the definition from Component for type Service instead of using opaqueType.
The text was updated successfully, but these errors were encountered:
Alternate issue title: @Discriminates needs a hierarchy traversal restriction
I was using the standard schema from
@frontside/backstage-plugin-graphql-backend-module-catalog
and came across an interesting condition.For reference, here is a snippet of the shipped schema file:
Component
andResource
are both entities that extend theEntity
interface, and they both have a fieldspec.type
which is used to drill down to more specific entity types via@discriminates
.In my catalog I have a
Resource
that is described withspec.type: service
, which causes an error to occur when querying the graphql endpoint:Query:
Error message in the GraphiQL client:
In the backend logs:
I can resolve the error by updating the schema to this:
It looks like the request is matching the
@discriminate
function onEntity
to map the entity to aResource
, but then whenResource
discriminates thespec.type
field, it is reading the definition fromComponent
for typeService
instead of usingopaqueType
.The text was updated successfully, but these errors were encountered: