Skip to content

Provide guidance on how to set up multiple GraphQL endpoints #439

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

Closed
dsarlo opened this issue Jul 15, 2022 · 7 comments
Closed

Provide guidance on how to set up multiple GraphQL endpoints #439

dsarlo opened this issue Jul 15, 2022 · 7 comments
Assignees
Labels
status: superseded Issue is superseded by another type: documentation A documentation task

Comments

@dsarlo
Copy link

dsarlo commented Jul 15, 2022

I want two separate endpoints, each with their own schemas to not expose our internal schemas to clients through GraphiQL. Both will need have different security configurations as well. (Just reiterating that this is something we need to do)

I found this stack overflow asking for something similar, but was hoping to see if someone more familiar with this project had a better way of doing something like this?

https://stackoverflow.com/questions/62202051/is-there-a-way-to-expose-2-graphql-endpoints-using-spring-boot-starter-app-graph

Any advice would be appreciated here!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 15, 2022
@dsarlo-viso
Copy link

dsarlo-viso commented Jul 20, 2022

@rstoyanchev Just wanted to provide a little update here. This is something that I was able to implement over the past few days successfully. If this is something you think would be worthwhile, I would love to help get something concrete into the spring for graphql project here (Perhaps more relevant to the starter project now that I'm thinking of it).

Just a few notes:

  1. Turned off the graphql web mvc auto config, took that code and created a second RouterFunction set up with the separate schema files and stored each of the GraphQlSource objects in a hashmap with their respective endpoints for later.
  2. Created a ExecutionGraphQlService bean with my custom MultiSourceExecutionGraphQlService (Implements the ExecutionGraphQlService interface) that takes the hashmap mentioned in the last step and uses the request uri to determine which GraphQlSource to use

I'm sure there is more to this, especially if you would want to support not just web mvc, but it's a start. Would love to hear your thoughts on this.

@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jul 20, 2022

Yes, I was going to comment along the same lines. The auto-config is really built for one GraphQL endpoint per JVM, but if you're willing to make your own config, it's not that much to replicate.

I think it would be useful to have a minimal sample of this for a start. The challenge with turning it into auto-config is that we won't be able to just detect the various beans like interceptors, exception resolvers, and others since it won't be clear which endpoint they belong to. However, we can give it more consideration if it becomes a common need.

@dsarlo-viso
Copy link

Thanks for the reply here. I'll set up a sample project for you when I have some time. I'd love to see this get implemented at some point

@bclozel bclozel self-assigned this Aug 4, 2022
@bclozel bclozel added the type: enhancement A general enhancement label Aug 4, 2022
@bclozel bclozel added this to the 1.0.2 milestone Aug 4, 2022
@rstoyanchev rstoyanchev changed the title Question: How to set up two different graphql endpoints, both with separate schemas? Provide guidance on how to set up multiple GraphQL endpoints Aug 4, 2022
@bclozel bclozel removed the status: waiting-for-triage An issue we've not yet triaged label Aug 4, 2022
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Aug 4, 2022

@dsarlo we'll experiment and document how to this. There might also be some small changes needed.

@bclozel bclozel modified the milestones: 1.0.2, 1.0.3 Sep 19, 2022
@danielgatis
Copy link

Guys, can you show some example how to do this configuration?

@dsarlo
Copy link
Author

dsarlo commented Oct 11, 2022

Guys, can you show some example how to do this configuration?

Hey! The general approach is described above. Still haven’t had time to create an example project. When I find the time, I’ll post here!

@bclozel bclozel removed this from the 1.0.3 milestone Nov 3, 2022
@bclozel bclozel added type: documentation A documentation task status: superseded Issue is superseded by another and removed type: enhancement A general enhancement labels Nov 3, 2022
@bclozel
Copy link
Member

bclozel commented Nov 3, 2022

We'll consider this as part of #208.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded Issue is superseded by another type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

6 participants