slnm
August 6, 2021, 10:23pm
1
Can someone please provide a curl example of fetching the schema definition. From the docs I tried this:
curl -H “Content-Type: application/json” -X POST localhost:8080/admin -d
‘{
getGQLSchema {
schema
}
}’ | python -m json.tool
I got this error:
“Not a valid GraphQL request body: invalid character ‘g’ looking for beginning of object key string”
Thanks!
iluminae
(Kenan Kessler)
August 6, 2021, 11:37pm
2
Try the content type application/graphql
as opposed to application/json.
slnm
August 8, 2021, 4:44pm
3
All I get is this with application/graphql:
"data": {
"getGQLSchema": null
}
There’s definitely a schema there; I can see it in Ratel.
MichelDiz
(Michel Diz)
August 8, 2021, 6:19pm
4
slnm:
I can see it in Ratel.
What you can see in Ratel is the DQL schema, and always you gonna see something there. You are querying for GraphQL Schema. If you didn’t created the GraphQL schema, it won’t show anything in the GraphQL request.
slnm
August 8, 2021, 6:44pm
5
Ok. What’s the curl command, including the Content-Type header, to see the DQL schema? That’s what I can’t piece together from the documentation. Thanks.
MichelDiz
(Michel Diz)
August 8, 2021, 9:10pm
6
Basically something like this:
curl -H "Content-Type: application/dql" localhost:8080/query -XPOST -d '{
schema {}
}' | python -m json.tool | less
See more at https://dgraph.io/docs/query-language/schema/#querying-schema
slnm
August 9, 2021, 2:28pm
7
That works great. Thank you!