Repository navigation
Why is my Interface-typed field fetcher not called when "... on Type" used? #2331
|
What am I doing wrong? There are no exceptions visible and the response comes back for this query: mutation {
mut: field1(argument2: "stringValue1", argument1:"stringValue2") {
bundle: bundle {
A: things {
id: id
container: container {
__typename
... on ThingContainerInterface {
id: id
}
... on Box {
name: name
content {
__typename
id: id
}
}
}
}
B: things {
id: id
container {
__typename
id: id
name: name
}
}
}
}
}Specifically:
I attached anonymized-then-partially-prettified schema and the response. For convenience here's the response too: {
"data": {
"mut": {
"bundle": {
"A": [
{
"id": "Thing#2",
"container": {
"__typename": "Box" // <-- notice the type - but no id or name
}
},
{
"id": "Thing#3",
"container": {
"__typename": "Box" // <-- notice the type - but no id or name
}
},
{
"id": "Thing#4",
"container": {
"__typename": "Box" // <-- notice the type - but no id or name
}
},
{
"id": "Thing#1",
"container": {
"__typename": "Box" // <-- notice the type - but no id or name
}
}
],
"B": [
{
"id": "Thing#2",
"container": {
"__typename": "Box",
"id": "Box#1",
"name": "Coyote"
}
},
{
"id": "Thing#3",
"container": {
"__typename": "Box",
"id": "Box#2",
"name": "Road Runner"
}
},
{
"id": "Thing#4",
"container": {
"__typename": "Box",
"id": "Box#2",
"name": "Road Runner"
}
},
{
"id": "Thing#1",
"container": {
"__typename": "Box",
"id": "Box#1",
"name": "Coyote"
}
}
]
}
}
}
}Note: I have verified - my code does return the correct, non-null |
Replies: 5 comments
|
Is this my defect (e.g. I don't / missed to enable/trigger something)? Is it something I can work around? Please help. |
|
I see from here that this is meant to work ... what could I have messed up? |
|
I was playing around with this. The following works as expected: #...
objectTypedField {
... on FieldObjectType {
id
}
}
#...... but only on fields that are of object types. That is of very little/no use to me as these types are leafs. I needed to specify the field selection for specific concrete type(s) for a field that is declared with an interface type, as noted in my original post: interfaceTypedField {
... on FieldObjectType {
id
}
}I even tried just re-stating the field's declared interface type ... and it does not work either: interfaceTypedField {
... on FieldInterfaceType {
id
}
}This is with |
|
This was not the issue. The issue was in my code and remained undetected by graphql-java. I had two instances of these types (with the same name) because I built them twice (using the same GraphQLObjectType.Builder instance. Only one of these was registered with the schema builder but another was used instead of type references in some cases. After ensuring that a single instance is built and used (or type references are), the issue disappeared. |
This was not the issue. The issue was in my code and remained undetected by graphql-java. I had two instances of these types (with the same name) because I built them twice (using the same GraphQLObjectType.Builder instance. Only one of these was registered with the schema builder but another was used instead of type references in some cases. After ensuring that a single instance is built and used (or type references are), the issue disappeared.