-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support playgroundPath #1974
Support playgroundPath #1974
Conversation
This one is huge! Thanks @mondaychen for knocking this out. I will take a look at this soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did check express
changes and they look good to me.
What's happening with this? It would be a huge win for us to have this since we need a way to "fake" a jwt token header when a developer is using the playground and we can't just turn off auth all together. |
hey @abernix can you say something about what are you going to do with this PR? I'm pretty sure you do read PRs diligently, but I have to say I feel terrible when my own PRs are open for almost a month with no comment from any maintainer. I understand this is not working on features or bugs with the highest priority, but I, along with several others, do believe this is a good feature to bring in and will use it immediately when a new version comes with this feature. Let me know if you
|
Hi, to answer point 1, I am upgrading Vulcan.js to Apollo 2 and this feature sounds necessary to us. Having Playground on the same endpoint as the |
Hi. |
@mondaychen Starting with your questions:
This is presently my feeling, yes, but I'll get into details below and perhaps I’ll feel differently after we discuss the feature some more.
Not at all! In fact, this appears to be of great quality! Thank you for submitting a high quality PR with tests, changes to the most popular integrations, CHANGELOGs, etc. I'm sorry if the delay in response led you to doubt the quality of your work!
Well, yes, but that's okay. There's a lot of PRs I'd like to get merged! There's generally just some concerns which are holding them up, and I'm hoping we can get better at communicating about those (and I'll try to explain how here!)
I did, but this is mostly the same as 3! I'm really sorry that it's taken so long to get back to you, I'm cognizant that much of the frustration (of many individuals above!) is likely due to the time. Ok.. that said, I realize you took some time to work on this, but to be relatively direct to everyone asking what the hold up is: you opened your own PR, for your own issue, after declaring it as a valid feature yourself, without consensus from the maintainers of the project. I'm not saying "Don't do that", but I'm afraid it's the reason there's some disappointment being voiced here by yourself and others. The requirements for submitting requests for new features are explained in the contributing guidelines. Those guidelines also specify to wait for consensus before opening a PR, especially for PRs which are more than ~20 lines. I hope you understand that every feature has a cost and we should be somewhat selective about what's accepted. Having concrete use-cases is a great place to start, and the original issue you opened didn't have that. This PR adds 200+ lines of code, so it's certainly not a trivial investment for the project and its my duty to try and look out for that, even if it comes at some discomfort. Anyhow, I hope you'll understand a number of my hesitation, particularly because I think there are other ways to do this and while flexibility is important, more flexibility often comes with more configuration and complexity. You did recently provide a use-case in the original issue:
I have some questions about this, namely:
Ignoring the fact that the
I don't think we can fix technical issues just because they're too original. 😄 Can you help me better understand the concerns to this approach that were brought up during the code review? Realistically, my temptation is to close this PR and take this to the design table in the original issue where I suspect we might actually find a reasonable workaround that doesn't bring this additional surface area, but we can hold off on that. I also have an inkling that if we can do a better job at the Improve integration with existing frameworks bullet-point in #2360, this might be as simple disabling Playground in Apollo Server (already possible with import { graphqlPlayground } from 'possibly-even-apollo-server-still';
someHttpFramework.use('/graphql-playground', graphqlPlayground({ service })); Anyhow, looking forward to improving this experience! Feedback appreciated. |
@abernix Thanks for the response. Your detailed response is highly appreciated even though some might not agree. Now we at least know the reasons. I figured out that when configuring apollo server we can tell the playground what endpoint it's gonna use, like this: const server = new ApolloServer({
schema: schema,
context: ({ req }) => createContext(req),
uploads: false,
playground: {
endpoint: "/graphql/dev",
},
}); ...then when we setup the context.... function createContext(request) {
if (isDevelopment()) {
if (request && request.originalUrl.endsWith("/graphql/dev")) {
// fake a user on the request...
request.user = {
name: "GRAPHQL DEVELOPMENT USER",
permissions: [SOME PERMISSIONS NEEDED],
roles: [SOME ROLES NEEDED],
};
}
}
.... ...we can just look for that endpoint being playground and then "fake" a request.user object... So, that's one option at least...and I can live with that ;) Keep up the good work you guys do! |
@abernix Thanks for this detailed response! To provide more info, what bothers me is the extra overhead due to the fact that the endpoint is I would reverse the question: are you sure that adding playground systematically to the It seems to at least complicate dev workflows. Also we can imagine other use cases: say that I want to tie an interface to the Note that I really like the syntax you provided here:
That would make Playground more consistent with how other libs are working and would totally solve this issue for me. |
@abernix I really appreciated your comment. In recent a few months, I've learned a lot about the workload and pressure that maintainers of a popular project are facing. Please accept my apologies for being too pushy and not waiting for a consensus. To answer your question:
|
Our team is in a similar situation as @mondaychen where we would prefer not to disable our gateway checks in the development environment. |
Also would love to have this feature. |
I'd love this feature also. I have a similar set up as @mondaychen. |
We have need of this functionality as well. To explain our specific need:
We need these endpoints to be completely separated and easily managed, separately. Having them bundled into a single endpoint separated only by an HTTP verb is making this difficult for us. |
We also require this functionality. Specifically, we would like to offer 2 URLs - one for the playground and one for a JSON representation. This was previously possible in a Hapi/GraphQL set up where we could manually register 2 distinct routes. No longer possible now we're using Apollo |
I can't say I understand how this could be described as something without a "valid use case." A rather obvious problem introduced by serving the playground on the same path as the GraphQL API itself is that it causes GraphQL GET requests (which are otherwise supported by apollo-server, as well they should be) to be swallowed by the middlewares serving the playground. So, even if I don't have gateway checks or other authentication middlewares that I need to bypass when serving the playground-- like others have mentioned-- I still can't use GET requests to my development instance without disabling the playground. To be perfectly honest, I'd consider this a fundamental design error-- something that probably should have been considered when adding the playground in the first place. The whole reason you put a graphql endpoint at its own path like I realize that we can turn off the automatically-added playground middlewares with |
I stumbled upon this PR looking for a solution on how to get the Playground URL different from the Graphql URL. It would allow us to bypass the passport authentication mechanism for Playground when being in development mode. Eagerly waiting fro this feature... |
GraphQL Playground's maintainers have retired the project. It is not the default experience as of last year's Apollo Server 3 and won't be distributed as a maintained part of Apollo Server starting with Apollo Server 4 (imminent). So we are not going to improve it. Sorry for the delay! |
This is to implement issue #1908
Please advise me on where I should add docs for this new feature. Thanks!
TODO: