Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphiQL seems to want to post to /graphiql even if that isn't where it's mounted #46

Closed
ndarilek opened this issue Jan 18, 2017 · 10 comments

Comments

@ndarilek
Copy link

I'd like to mount GraphiQL to /api, which will also be the GraphQL API endpoint, to make it just a bit easier to discover and experiment with the API.

Even if I mount the GraphiQL plug at /api, it still wants to post to /graphiql. I have a hacky workaround in that I mount the plain GraphQL API at /graphiql, then point everything else at /api.

Any idea why this is happening? A quick glance through the source isn't hugely revealing. I'm wondering if it is a GraphiQL default that isn't being updated via the plug? If so, seems like it would fail if mounted anywhere else.

As an aside, is there any reason why doing this would be a bad idea? I'm explicitly trying to make this API as easy to discover and use as possible, but maybe there are gotchas of which I'm not aware.

Thanks.

@benwilson512
Copy link
Contributor

The GraphiQL that we have mounted by default lets you specify where to send queries.
image
Are you unable to enter the correct URL there?

@ndarilek
Copy link
Author

ndarilek commented Jan 18, 2017 via email

@benwilson512
Copy link
Contributor

It was my understanding that it would use the current location, but possibly not. This sounds like perhaps an issue that belongs on the graphiql project itself, it's a generic piece of javascript that while we provide an easy integration are not its authors.

@ndarilek
Copy link
Author

ndarilek commented Jan 18, 2017 via email

@ndarilek
Copy link
Author

ndarilek commented Jan 18, 2017 via email

@benwilson512
Copy link
Contributor

I think you're confused about where this functionality exists. This functionality is not written in Elixir. We provide an EEX template, but that template literally just links to another project's javascript here: https://github.com/absinthe-graphql/absinthe_plug/blob/master/lib/absinthe/plug/graphql_toolbox.html.eex#L29

A few lines lower we pass in a tiny bit of config, which puts the default URL at the window location. That's it, everything else happens in the javascript contained in a totally different project. This is why I closed the issue, there's no evidence that changing code in this project will help you.

I do however have a theory about your issue. This particular GraphIQL tool uses local storage to persist a bunch of information, including the URL. Use the inspector to clear out the local storage for your host and see if that fixes it.

@ndarilek
Copy link
Author

ndarilek commented Jan 18, 2017 via email

@benwilson512
Copy link
Contributor

Do note that the javascript you linked to appears to be for the simplified graphiql interface whereas by default Absinthe exposes https://github.com/OlegIlyenko/graphql-toolbox which is a lot more advanced.

@benwilson512
Copy link
Contributor

Glad that helped :)

@bruce
Copy link
Contributor

bruce commented Jan 18, 2017

Note we do want to update the version we link to as well: #37 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants