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

feat: update graphql type informer to handle circular dependencies be… #1571

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hendrik-depauw-lemon
Copy link
Contributor

Description

The graphql type informer could not handle circular dependencies between types. The result would always be JSON. By using thunks, we can fix this issue.

Changes

  • Use thunks to define graphql fields

Checks

  • Project Builds
  • Project passes tests and checks
  • Updated documentation accordingly

Additional information

We are using Object.assign on the graphqlTypes map so that the references to the types do not change. However, when we want to update the fields of the type, we need an internal function from the graphql package that is currently not exported. What course of action do you guys suggest? Should we open a PR to graphql? Do we patch graphql? Do we copy the internals of the function? Other options?

Copy link

what-the-diff bot commented Mar 5, 2025

PR Summary

  • Utility Importation from graphql/type/definition
    The code now imports defineFieldMap function from the aforementioned module. This function will be used to help define fields in our program.

  • Introduction of Type Placeholder to Handle Circular References
    We have added a placeholder for types in both getOrCreateInputType and createOutputObjectType methods. This placeholder aids in managing and resolving circular references, thus ensuring that our code is less prone to errors and is more efficient.

  • Use of Object.assign for Object Creation
    The direct creation of GraphQLInputObjectType and GraphQLObjectType has been replaced. Instead, we've updated the this.graphQLTypes using Object.assign. By doing this,objects can be duplicated and merged more effectively, leading to better data management.

  • Field Definition through _fields Property
    In the input and output object types, we are now using the _fields property. Partnered with defineFieldMap utility, it helps in defining fields in our types.

  • Simplification of Return Statements
    The return statements were simplified to just return the existing type from this.graphQLTypes. This leads to cleaner code while maintaining efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant