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

Extends FieldArgTypeCoercion #50

Conversation

AndresPrez
Copy link
Contributor

@AndresPrez AndresPrez commented May 24, 2022

Hello @chanind, here's an extension proposal for the FieldArgTypeRewriter rewriter.

This PR is backwards compatible.

New functionalities are included for the FieldArgTypeRewriter rewriter.

  1. fieldName now optional in case matchConditions are passed: Useful to avoid having to create a new rewriter for every field, as now the matching can be delegated to the matchConditions

  2. coerceVariable function now receives context in second argument: Context includes all of query's variables and arguments, and very useful for coercion that needs the value of other argument values as in pagination coercion (e.g., [limit, offset] to [pageSize, pageNumber])

  3. In-Query argument values can be coerced: _Now, there's the coerceArgumentValue that allows support when argument values come in the query document.

  4. Unit Tests for new functionalities

@AndresPrez AndresPrez changed the title Improves FieldArgTypeCoercion Extends FieldArgTypeCoercion May 24, 2022
@AndresPrez AndresPrez force-pushed the feature/ap/arg-type-better-coercion branch from 3302a20 to b73c68a Compare May 25, 2022 22:52
Copy link
Collaborator

@chanind chanind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great idea! I'm not sure why test/linting isn't running against the PR in CI, so I'll just verify that it passes manually later

src/rewriters/Rewriter.ts Outdated Show resolved Hide resolved
src/rewriters/Rewriter.ts Outdated Show resolved Hide resolved
@AndresPrez
Copy link
Contributor Author

Hey @chanind, thanks for taking a look at this. Ive fixed the lint issues and your suggestions as well.


// If no fieldName is provided, check for defined matchConditions.
// This avoids having to define one rewriter for many fields individually.
// Alternatively, regex matching for fieldName could be implemented.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this is a cool idea for a future PR!

Copy link
Collaborator

@chanind chanind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay getting back to you! This looks great, but it looks like linting is failing. If you run yarn lint you can see the linting failures. If these can be fixed I think this should be good to go! apologies I was on the old version still!

@chanind chanind merged commit 9dbcdea into graphql-query-rewriter:master May 29, 2022
@chanind
Copy link
Collaborator

chanind commented May 29, 2022

🎉 This PR is included in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@AndresPrez AndresPrez deleted the feature/ap/arg-type-better-coercion branch May 31, 2022 17:08
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.

2 participants