Skip to content

Support for Anyc creation of GraphQl Schema #989

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
djett41 opened this issue May 31, 2024 · 2 comments
Closed

Support for Anyc creation of GraphQl Schema #989

djett41 opened this issue May 31, 2024 · 2 comments
Labels
for: external-project Needs a change in external project in: core Issues related to config and core support status: duplicate A duplicate of another issue

Comments

@djett41
Copy link

djett41 commented May 31, 2024

Hello! I have the following usecase and have been digging around but don't see any documentation that supports my usecase which requires generating a GraphQl schema at runtime. If anyone has seen this done before please point me in the right direction :-) I appreciate it!

  1. When the app starts, hit an external API to grab the configuration files of different Types and fields for that type.
  2. Dynamically create a graphql Schema with queries/mutations/subscriptions/query inputs etc based on those fields/types loaded from the exernal API
  3. Allow for the server to be able to perform CRUD operations against another API for each type
  4. Have a tool like Graphiql update to show the latest types and fields and allow you to query/mutate each type

Is this possible in spring-graphql at the moment? Thanks!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 31, 2024
@bclozel bclozel added status: duplicate A duplicate of another issue for: external-project Needs a change in external project in: core Issues related to config and core support and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 3, 2024
@bclozel
Copy link
Member

bclozel commented Jun 3, 2024

Your application can provide its own GraphQlSource bean for that. Right now, there is a small limitation in the Spring Boot auto-configuration where a schema file on disk is still required, even if it is empty. This limitation is considered under spring-projects/spring-boot#33096

Other than that, Spring for GraphQL should support your use case just fine.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2024
@rstoyanchev
Copy link
Contributor

AbstractGraphQlSourceBuilder has two sub-classes, one with the default way in which we initialize the GraphQLSchema e.g. by parsing schema files, and another with a given GraphQLSchema instance. You can probably use that as a base class, and override the initGraphQlSchema method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a change in external project in: core Issues related to config and core support status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants