Module version(s) affected
4.3.5+
Description
I’ve been seeing the following warning from some projects with GraphQL, have finally decided to stop ignoring them and investigate:
E_WARNING: Undefined property: GraphQL\Language\AST\VariableNode::$fields
from this line specifically:
https://github.com/silverstripe/silverstripe-graphql/blob/4.3.7/src/Schema/Traits/SortTrait.php#L49
I assume the code isn’t expecting a VariableNode instance
Appears to be a regression from #563 (4.3.4 doesn’t produce the warning, 4.3.5 and up does).
I don’t fully understand the code here, so I’m not sure why this is occurring yet. I’ll try to do some more testing tomorrow.
I’ve only confirmed this against SS4 (GraphQL v4) but I suspect the same issue would apply to SS5.
How to reproduce
The best I can offer at this stage is an example of the schema:
SilverStripe\Blog\Model\BlogPost:
fields:
id: true
title: true
urlSegment: true
link: true
editorsPick: true
timeToRead: true
publishDate: true
timesViewed: true
parentId: true
epochPublishDate:
type: 'int'
cardImageSrc:
type: 'string'
minutesToRead:
type: 'string'
estimatedTimeToConsume:
type: 'string'
renderCard:
type: 'string'
operations:
read: true
And an example query:
{
"operationName": "ReadBlogPosts",
"query":
"query ReadBlogPosts($filter: BlogPostFilterFields, $sort: BlogPostSortFields, $offset: Int, $limit: Int) {
readBlogPosts(filter: $filter, sort: $sort, offset: $offset, limit: $limit) {
edges: nodes {
id
title
editorsPick
publishDate
cardImageSrc
estimatedTimeToConsume
link
epochPublishDate
renderCard
__typename
}
pageInfo {
totalCount
hasNextPage
hasPreviousPage
__typename
}
__typename
}
}"
,
"variables": {
"filter": {},
"limit": 6,
"offset": 0,
"sort": []
}
}
Possible Solution
No response
Additional Context
No response
Validations
PRs
Module version(s) affected
4.3.5+
Description
I’ve been seeing the following warning from some projects with GraphQL, have finally decided to stop ignoring them and investigate:
from this line specifically:
https://github.com/silverstripe/silverstripe-graphql/blob/4.3.7/src/Schema/Traits/SortTrait.php#L49
I assume the code isn’t expecting a
VariableNodeinstanceAppears to be a regression from #563 (
4.3.4doesn’t produce the warning,4.3.5and up does).I don’t fully understand the code here, so I’m not sure why this is occurring yet. I’ll try to do some more testing tomorrow.
I’ve only confirmed this against SS4 (GraphQL v4) but I suspect the same issue would apply to SS5.
How to reproduce
The best I can offer at this stage is an example of the schema:
And an example query:
{ "operationName": "ReadBlogPosts", "query": "query ReadBlogPosts($filter: BlogPostFilterFields, $sort: BlogPostSortFields, $offset: Int, $limit: Int) { readBlogPosts(filter: $filter, sort: $sort, offset: $offset, limit: $limit) { edges: nodes { id title editorsPick publishDate cardImageSrc estimatedTimeToConsume link epochPublishDate renderCard __typename } pageInfo { totalCount hasNextPage hasPreviousPage __typename } __typename } }" , "variables": { "filter": {}, "limit": 6, "offset": 0, "sort": [] } }Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer(with any code examples you've provided)PRs