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

[BUG] graphiql is not accessible #243

Closed
jplhomer opened this issue Nov 16, 2021 · 6 comments · Fixed by #248
Closed

[BUG] graphiql is not accessible #243

jplhomer opened this issue Nov 16, 2021 · 6 comments · Fixed by #248
Labels
bug Something isn't working

Comments

@jplhomer
Copy link
Contributor

Describe the bug
Graphiql explorer should be available at:

But instead, the Hydrogen 404 template is returned.

To Reproduce

@jplhomer jplhomer added the bug Something isn't working label Nov 16, 2021
@jplhomer
Copy link
Contributor Author

Hmm odd - this is working in stackblitz. Something we shipped but haven't yet released?

@blittle
Copy link
Contributor

blittle commented Nov 16, 2021

I wonder if it has to do with the work that @frandiox did to fix the static file routing.

@blittle blittle self-assigned this Nov 16, 2021
@blittle
Copy link
Contributor

blittle commented Nov 16, 2021

The static file routing did cause the problem. The vite default middlewares, which run first now, rewrite the request.url property to be /index.html. See the logic here. A work around is vite under the hood also uses connect-history-api-fallback, which has logic that doesn't rewrite to /index.html if the path contains a dot. So http://localhost:3000/graphiql.html does work.

@blittle
Copy link
Contributor

blittle commented Nov 16, 2021

I'm not sure the best way to resolve this. Maybe @frandiox has some ideas.

@blittle blittle removed their assignment Nov 16, 2021
@jplhomer
Copy link
Contributor Author

Hmmm. Maybe we could split the Graphiql logic into a separate plugin, and run the middleware before Vite's?

@blittle
Copy link
Contributor

blittle commented Nov 16, 2021

That's a good option. It seems odd that there isn't a way to configure this in vite though.

blittle added a commit that referenced this issue Nov 16, 2021
The default vite middleware rewrites the URL `/graphiql` to `/index.html`
Running the `/graphiql` middleware first prevents that.
blittle added a commit that referenced this issue Nov 16, 2021
The default vite middleware rewrites the URL `/graphiql` to `/index.html`
Running the `/graphiql` middleware first prevents that.
blittle added a commit that referenced this issue Nov 17, 2021
fix(#243): fix graphiql by running graphiql middleware before vite
rafaelstz pushed a commit to rafaelstz/hydrogen that referenced this issue Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants