SilverStripe GraphQL - error when querying types with descendants
up vote
1
down vote
favorite
I'm getting this error when trying to query a type and a descendant:
"Fragment cannot be spread here as objects of type "AppTestObject" can never be of type "AppTestChild"."
I set up a test install using recipe-core, admin, graphql, and graphql-devtools (all latest) to test this out in a basic setting. I've created 2 objects:
class TestObject extends DataObject {
private static $singular_name = "Test Object";
private static $plural_name = "Test Objects";
private static $table_name = "TestObject";
private static $db = [
'Title' => 'Varchar(255)'
];
}
class TestChild extends DataObject {
private static $singular_name = "Test Child";
private static $plural_name = "Test Children";
private static $table_name = "TestChild";
private static $db = [
'Title' => 'Varchar(255)'
];
}
And set up simple scaffolding through configuration:
SilverStripeGraphQLController:
schema:
scaffolding:
types:
AppTestObject:
fields: [ID]
operations:
read: true
AppTestChild:
fields: [ID, Title]
operations:
read: true
I'm able to query each of these types individually without any problems. But when I try to get TestChild
as a descendant of TestObject
I get the error above. Here's an example of my query:
query {
readAppTestObjects {
edges {
node {
...on AppTestChild {
Title
}
}
}
}
}
Checking the documentation for the schema in graphiql, there is nothing under readAppTestObjects
referencing descendants, although in the documentation for silverstripe/graphql it says:
When reading types that have exposed descendants (e.g. reading Page, when RedirectorPage is also exposed), the return type is a union of the base type and all exposed descendants. This union type takes on the name {BaseType}WithDescendants.
php graphql silverstripe silverstripe-4
add a comment |
up vote
1
down vote
favorite
I'm getting this error when trying to query a type and a descendant:
"Fragment cannot be spread here as objects of type "AppTestObject" can never be of type "AppTestChild"."
I set up a test install using recipe-core, admin, graphql, and graphql-devtools (all latest) to test this out in a basic setting. I've created 2 objects:
class TestObject extends DataObject {
private static $singular_name = "Test Object";
private static $plural_name = "Test Objects";
private static $table_name = "TestObject";
private static $db = [
'Title' => 'Varchar(255)'
];
}
class TestChild extends DataObject {
private static $singular_name = "Test Child";
private static $plural_name = "Test Children";
private static $table_name = "TestChild";
private static $db = [
'Title' => 'Varchar(255)'
];
}
And set up simple scaffolding through configuration:
SilverStripeGraphQLController:
schema:
scaffolding:
types:
AppTestObject:
fields: [ID]
operations:
read: true
AppTestChild:
fields: [ID, Title]
operations:
read: true
I'm able to query each of these types individually without any problems. But when I try to get TestChild
as a descendant of TestObject
I get the error above. Here's an example of my query:
query {
readAppTestObjects {
edges {
node {
...on AppTestChild {
Title
}
}
}
}
}
Checking the documentation for the schema in graphiql, there is nothing under readAppTestObjects
referencing descendants, although in the documentation for silverstripe/graphql it says:
When reading types that have exposed descendants (e.g. reading Page, when RedirectorPage is also exposed), the return type is a union of the base type and all exposed descendants. This union type takes on the name {BaseType}WithDescendants.
php graphql silverstripe silverstripe-4
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm getting this error when trying to query a type and a descendant:
"Fragment cannot be spread here as objects of type "AppTestObject" can never be of type "AppTestChild"."
I set up a test install using recipe-core, admin, graphql, and graphql-devtools (all latest) to test this out in a basic setting. I've created 2 objects:
class TestObject extends DataObject {
private static $singular_name = "Test Object";
private static $plural_name = "Test Objects";
private static $table_name = "TestObject";
private static $db = [
'Title' => 'Varchar(255)'
];
}
class TestChild extends DataObject {
private static $singular_name = "Test Child";
private static $plural_name = "Test Children";
private static $table_name = "TestChild";
private static $db = [
'Title' => 'Varchar(255)'
];
}
And set up simple scaffolding through configuration:
SilverStripeGraphQLController:
schema:
scaffolding:
types:
AppTestObject:
fields: [ID]
operations:
read: true
AppTestChild:
fields: [ID, Title]
operations:
read: true
I'm able to query each of these types individually without any problems. But when I try to get TestChild
as a descendant of TestObject
I get the error above. Here's an example of my query:
query {
readAppTestObjects {
edges {
node {
...on AppTestChild {
Title
}
}
}
}
}
Checking the documentation for the schema in graphiql, there is nothing under readAppTestObjects
referencing descendants, although in the documentation for silverstripe/graphql it says:
When reading types that have exposed descendants (e.g. reading Page, when RedirectorPage is also exposed), the return type is a union of the base type and all exposed descendants. This union type takes on the name {BaseType}WithDescendants.
php graphql silverstripe silverstripe-4
I'm getting this error when trying to query a type and a descendant:
"Fragment cannot be spread here as objects of type "AppTestObject" can never be of type "AppTestChild"."
I set up a test install using recipe-core, admin, graphql, and graphql-devtools (all latest) to test this out in a basic setting. I've created 2 objects:
class TestObject extends DataObject {
private static $singular_name = "Test Object";
private static $plural_name = "Test Objects";
private static $table_name = "TestObject";
private static $db = [
'Title' => 'Varchar(255)'
];
}
class TestChild extends DataObject {
private static $singular_name = "Test Child";
private static $plural_name = "Test Children";
private static $table_name = "TestChild";
private static $db = [
'Title' => 'Varchar(255)'
];
}
And set up simple scaffolding through configuration:
SilverStripeGraphQLController:
schema:
scaffolding:
types:
AppTestObject:
fields: [ID]
operations:
read: true
AppTestChild:
fields: [ID, Title]
operations:
read: true
I'm able to query each of these types individually without any problems. But when I try to get TestChild
as a descendant of TestObject
I get the error above. Here's an example of my query:
query {
readAppTestObjects {
edges {
node {
...on AppTestChild {
Title
}
}
}
}
}
Checking the documentation for the schema in graphiql, there is nothing under readAppTestObjects
referencing descendants, although in the documentation for silverstripe/graphql it says:
When reading types that have exposed descendants (e.g. reading Page, when RedirectorPage is also exposed), the return type is a union of the base type and all exposed descendants. This union type takes on the name {BaseType}WithDescendants.
php graphql silverstripe silverstripe-4
php graphql silverstripe silverstripe-4
edited Nov 7 at 10:25
Robbie Averill
20.4k73976
20.4k73976
asked Nov 7 at 5:47
Chris
1589
1589
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Yeah this is a bug in the SilverStripe graphql module. What you're doing should work.
I believe the fix is in flight at https://github.com/silverstripe/silverstripe-graphql/pull/176, you can follow the progress there. Maybe try the patch out and leave some comments.
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Yeah this is a bug in the SilverStripe graphql module. What you're doing should work.
I believe the fix is in flight at https://github.com/silverstripe/silverstripe-graphql/pull/176, you can follow the progress there. Maybe try the patch out and leave some comments.
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
add a comment |
up vote
1
down vote
accepted
Yeah this is a bug in the SilverStripe graphql module. What you're doing should work.
I believe the fix is in flight at https://github.com/silverstripe/silverstripe-graphql/pull/176, you can follow the progress there. Maybe try the patch out and leave some comments.
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Yeah this is a bug in the SilverStripe graphql module. What you're doing should work.
I believe the fix is in flight at https://github.com/silverstripe/silverstripe-graphql/pull/176, you can follow the progress there. Maybe try the patch out and leave some comments.
Yeah this is a bug in the SilverStripe graphql module. What you're doing should work.
I believe the fix is in flight at https://github.com/silverstripe/silverstripe-graphql/pull/176, you can follow the progress there. Maybe try the patch out and leave some comments.
answered Nov 7 at 10:27
Robbie Averill
20.4k73976
20.4k73976
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
add a comment |
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Robbie, you're a gem. This fixed the issue.
– Chris
Nov 8 at 20:16
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
Please direct credit at the pull request author on GitHub ;)
– Robbie Averill
Nov 8 at 20:27
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53184168%2fsilverstripe-graphql-error-when-querying-types-with-descendants%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown