Reputation: 28810
I have a gatsby blog that I push to aws with amplify.
Locally I can query my gatsby website by running queries such against the http://localhost:8000/__graphql
endpoint like this:
curl 'http://localhost:8000/__graphql?' -H 'Connection: keep-alive' -H 'Accept: application/json' -H 'Sec-Fetch-Dest: empty' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36' -H 'Content-Type: application/json' http://localhost:8000/' --data-binary '{"query":"query MyQuery {\n site(children: {elemMatch: {}}) {\n id\n }\n allDirectory {\n edges {\n node {\n id\n }\n }\n }\n allFile {\n edges {\n node {\n id\n }\n }\n }\n allSitePage {\n pageInfo {\n currentPage\n itemCount\n }\n }\n}\n","variables":null,"operationName":"MyQuery"}' --compressed
How can I expose the __graphql
endpoint in production?
Upvotes: 1
Views: 519
Reputation: 445
Stumbled on your question and I think the answer is Yes you can kind of do that, but should you do it the anwser is no.
The thing is that gatsbys internal graphql api is working with the local file system, and because gatsby is kind of serverless technology it would really be kind of wierd to use it as an api.
But in this issue I found out that what you are seeking is possible, but not primarily the direction where gatsby is going. https://github.com/gatsbyjs/gatsby/issues/21616
Hope it helps or answers your question.
Upvotes: 1