Peter
10 March 2019 20:56
1
Silverstripe Version: 4.3
Question:
I have setup GraphQL with an empty config and as far as I can tell I should be getting a result for the query:
/graphql/?query={__schema{types{kind+name+description}}}
I have set up the route with
SilverStripe\Control\Director:
rules:
'graphql': '%$SilverStripe\GraphQL\Controller.default'
but all I get back is an error - “Schema query must be Object Type but got: NULL”
The route /admin/graphql is working and gives me the expected result
I have obviously missed something pretty basic, so if anyone can point me in the right direction it would be appreciated
blueo
10 March 2019 23:47
2
answered in slack but to follow up:
I just have a test project set up and I found this:
just setting the director rule (route) is not enough - it gives the same error
as soon as I added a type to the scheme eg
SilverStripe\GraphQL\Manager:
schemas:
default:
scaffolding:
types:
Page:
fields: [ID, Title, Content]
operations:
read: true
create: true
it works… so maybe the schema can’t be empty?
Peter
10 March 2019 23:49
4
Haha, snap.
Thanks a lot, what little hair I have is now intact
Peter
10 March 2019 23:48
3
It seems that you can’t run it with no setup at all. There needs to be at least one type set up, e.g.:
SilverStripe\GraphQL\Manager:
schemas:
default:
scaffolding:
types:
Page:
fields: [ID, Title, Content]
operations:
read: true
readOne: true
Thanks to blueo