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

Modify ast nodes when transforming schemas #1762

Merged
merged 6 commits into from Jul 13, 2020

Conversation

yaacovCR
Copy link
Collaborator

@yaacovCR yaacovCR commented Jul 13, 2020

Each transform should also modify the underlying astnode and extensionASTNodes, if they exist.

This PR also changes mapSchema to automatically update a type's astNode list of field definitions to match the actual field definitions includes within the type's new config map after mapping.

There is likely space for making sure to update additional astNodes within types to match the enclosed graphql type system objects, for example, enum types with the enclosed enum values. That may be included in a separate PR at this time.

Addresses #1747

Each transform should also modify the underlying astnode and extensionASTNodes, if they exist.

Initial change adds ast modification to:
= RenameTypes
= TransformCompositeFields

TransformCompositeFields provides implementation for additional transforms:
= TransformRootFields
= FilterRootFields
= RenameRootFields
= TransformObjectFields
= FilterObjectFields
= RenameObjectFields
= TransformInterfaceFields
= FilterInterfaceFields
= RenameInterfaceFields

Still to do:
= WrapFields (which provides implementation of WrapType)
= HoistFields
= PruneSchema
= TransformInputIbjectFields (which provides implementation of FilterInputObjectFields and RenameInputObjectFields)
@theguild-bot
Copy link
Collaborator

theguild-bot commented Jul 13, 2020

The latest changes of this PR are available as alpha in npm: 6.0.13-alpha-81e668d8.0

Quickly update your package.json by running:

npx match-version @graphql-tools 6.0.13-alpha-81e668d8.0

as well as implementing transforms FilterInputObjetFields and RenameInputObjectFields
Alas. This should be called MapFieldNodes, possible can be changes in the next major version.
and implementing transform WrapType
type astNodes can be updated to only include the ast for fields remaining after mapping
@yaacovCR yaacovCR merged commit 81e668d into master Jul 13, 2020
@yaacovCR yaacovCR deleted the transforms-should-modify-ast-nodes branch July 13, 2020 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants