Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Add graphql curl example #805

Open
glensc opened this issue Nov 5, 2021 · 10 comments
Open

Add graphql curl example #805

glensc opened this issue Nov 5, 2021 · 10 comments
Assignees

Comments

@glensc
Copy link
Contributor

glensc commented Nov 5, 2021

Add curl example how to make query:

I tried to setup that example, and using graphql-playground I get just error "Failed to fetch schema"

image

@leocavalcante
Copy link
Owner

You don't need the .php in the path. It should be just /graphql.

@glensc
Copy link
Contributor Author

glensc commented Nov 5, 2021

my entry point is graphql.php, not index.php:

started with php -S:

php73 -S eventum.127.0.0.1.xip.io:8012 -t htdocs -d variables_order=EGPCS

@glensc
Copy link
Contributor Author

glensc commented Nov 5, 2021

So, tested with /graphql in PATH_INFO, the resonse is empty:

➔ curl -i 'http://localhost:8012/graphql.php/graphql'  --data-binary '{"query":"{    hello }"}'
HTTP/1.1 200 OK
Host: localhost:8012
Date: Fri, 05 Nov 2021 11:14:53 GMT
Connection: close
X-Powered-By: PHP/7.3.32
Content-type: text/html; charset=UTF-8

@leocavalcante
Copy link
Owner

leocavalcante commented Nov 5, 2021

Try http://localhost:8012/graphql you don't need to put the filename on the path, even if it isn't named index.php.

@glensc
Copy link
Contributor Author

glensc commented Nov 5, 2021

http://localhost:8012/graphql resolves to htdocs/index.php, which is a different application in that repository.

@trollboy
Copy link
Contributor

@glensc that's your problem. I believe there's two ways to accomplish what you're wanting to do via the paradigms of siler,
Solution 1:
install siler in htdocs/graphql, this is mildly hinky as you may run into issues with the application running in htdocs/index.php
Solution 2:
take your code from https://github.com/glensc/eventum/blob/9b1295e70dd97945efadb1b713c9355491cfdad4/htdocs/graphql.php and put it into the htdocs/index.php along side your other application.

@trollboy
Copy link
Contributor

If it helps, I'm working on something currently where I define my model structure using a custom ORM (sorry, I can't like RedBeans), and then enabling /rest and /graphql in my htdocs/graphql. Two completely different interfaces to the same data.

@glensc
Copy link
Contributor Author

glensc commented Nov 21, 2021

@trollboy the issue is not about my problems, but asking for curl graphql example to be put to readme.

@trollboy
Copy link
Contributor

so, I can do that for you now, however I'd recommend some sort of graphql library to do that. One moment.

@trollboy
Copy link
Contributor

like tons of examples online exist; see https://www.contentful.com/blog/2021/01/14/GraphQL-via-HTTP-in-five-ways/#php

@glensc glensc changed the title Graphql example Add graphql curl example Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants