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 question/feature request: show graphql endpoint being queried #2549

Closed
joshft91 opened this issue Jul 8, 2022 · 9 comments
Closed

Comments

@joshft91
Copy link

joshft91 commented Jul 8, 2022

My team is currently using GraphQL Playground that's shipped with Apollo Server, but due to the fact that Playground is no longer maintained and GraphiQL is now preferred, we are looking to switch. I'm currently running GraphiQL locally as outlined here.

One thing I appreciated about the GraphQL Playground is the ability to see which GraphQL endpoint was being hit/queried as seen in the screenshot below. Is this possible in GraphiQL or GraphiQL v2 that is being worked on?

image

If this wasn't the appropriate place to ask let me know and I can direct my question appropriately. Thank you!

@joshft91 joshft91 changed the title GraphiQL question/ - show graphql endpoint being queried GraphiQL question/feature request: show graphql endpoint being queried Jul 8, 2022
@acao
Copy link
Member

acao commented Jul 13, 2022

This might be good to consider as a 3.0.0 feature. The current API doesn't allow users to specify a UI directly, instead the fetcher takes this in as an internal detail, however the idea of making (multiple) URI endpoints a configuration feature in 3.0.0 is something that could make sense!

This would work if, for example a simple uri prop or a graphql-config like config object could conditionally be provided instead of the required fetcher. This would require props overloads but it would enable us to have per-endpoint headers, fetcher configuration, etc manageable in the UI

@thomasheyenbrock
Copy link
Collaborator

Hey @joshft91 👋 just wanna ask a clarifying question: Is your feature request just about showing the one URL that's used to send queries to? Or is it about adding support for querying multiple endpoints in a single instance of GraphiQL?

@joshft91
Copy link
Author

joshft91 commented Jul 13, 2022

Hey @acao and @thomasheyenbrock 👋 - thanks for the responses!

Good clarifying question - I was in the middle of a response to do just that. While I like the idea of querying multiple endpoints, my request/question was simpler (famous last words): display/show (read only) the URL that's configured in the fetcher essentially. It seems that this could be useful to me as a UI user of GraphiQL to know where my queries are being sent.

I believe this could even tie in with #2485 which seems like it's basically asking for a refresh button to trigger the introspection query. Something like what GraphQL Playground does now, just without the ability to specify a different endpoint.
image

Hope that makes sense!

@thomasheyenbrock
Copy link
Collaborator

thomasheyenbrock commented Jul 13, 2022

Thanks for clarifying 🙌 We'll implement schema reloading with the new design that will ship with v2. The button for that will likely be placed in a menu or dialog. There will also be a keyboard shortcut for that (probably Cmd/Ctrl + R). I don't see an obvious spot where we could show the endpoint in the new design, but this should be solvable in future iterations.

@acao Sounds like we won't need a new major for that, so labeling this just as "enhancement".

@acao
Copy link
Member

acao commented Jul 30, 2022

@thomasheyenbrock another pattern we can borrow from GraphQLPlayground is multiple service-layer components, which it seems you're already moving to to some degree.

GraphiQL could remain the component you use when you want to provide fetcher directly, and then GraphiQLEditor or some such could be more heavy-weight and act as an abstraction around GraphiQL and createFetcher() and eventually createRouter() (simple query params parser, maybe more some day?) and other details i imagined might be useful at this level.

For later major versions, 4 or 5 even at this point, it could eventually be something like this, like playground but with plugins. Perhaps the projects idea still makes sense though

const token = import.meta.env.TOKEN

// we could even adhere to `graphql-config` format, which this is an adaptation of
const projects = [
  { 
    name: "local",  schema: "localhost:3000/graphql"
  }, 
  { 
    name: "stage", 
    schema: "https://myschema.com/graphql", 
    headers: { Authorization: `bearer ${token}` } 
  }
]
<GraphiQLEditor
   projects={projects} 
   settings={/* JSON string like playground or perhaps object */} 
   plugins={/*array of components and/or modules definitions or objects*/} 
/>

which opens us to other playground-esque service layers for server middlewares and beyond!
there may be other issues with this approach though, I would be happy to hear other suggestions!

Then you open up so many options if we have some degree of graphql-config compatibility. For example, vite & webpack plugins to automatically build a graphiql instance from your graphql-config, and perhaps even pre-load query collections from your codebase when we support that in later versions

@acao
Copy link
Member

acao commented Jul 30, 2022

playground has so many great service layer design patterns that I want to clone for the more modern era haha! but one at a time, one at a time

@thomasheyenbrock
Copy link
Collaborator

@acao great ideas! But should we keep this issue scoped for now on showing the endpoint somewhere in the design and open up another one that focusses on multi-project support? (Maybe there already is one?)

@SachaG
Copy link

SachaG commented Aug 19, 2022

Is your feature request just about showing the one URL that's used to send queries to? Or is it about adding support for querying multiple endpoints in a single instance of GraphiQL?

Actually if I may I'd like to put in a vote for supporting querying multiple endpoints in a single GraphiQL instance. That would be super useful!

@acao
Copy link
Member

acao commented Feb 16, 2023

That is part of this feature request!

Lets track it here, since it documents the architectural changes needed to achieve this

@thomasheyenbrock in order to even show the url, we will need to make fetcherOpts required over fetcher prop. If fetcher prop is passed, then we cannot track the url in state, thus the proposal

@acao acao closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants