以下GraphQL查询runs perfectly fine in Github GraphQL Explorer:
$ cat GraphQL_query.graphql
query {
__schema {
types {
name
kind
description
fields {
name
}
}
}
}
但是,当我通过curl
发送时:
curl -H "Authorization: bearer token" -X POST -d "`cat GraphQL_query.graphql`" https://api.github.com/graphql
我会得到:
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v4"
}
怎么了?我怎样才能使它有效? THX。
答案 0 :(得分:2)
curl
语法对于该查询看起来像这样:
$ curl -H "Authorization: Bearer $GITHUB_PRODUCTION_TOKEN" https://api.github.com/graphql -X POST -d '{"query":"query { __schema { types { name kind description fields { name } } } }","variables":"{}"}'