graphql-query-rewriter / core

Seamlessly turn breaking GraphQL changes into non-breaking changes
https://graphql-query-rewriter.github.io/core
MIT License
407 stars 15 forks source link

feat: allow rewriters to modify parent result #22

Closed gregbty closed 3 years ago

gregbty commented 3 years ago

This updates the behavior of Rewriter so that the parent result is modified and returned instead of expecting the result of the modified key path. This is a follow-up to #20. I have successfully used this to create a rewriter capable of renaming fields.

I pushed this as a breaking change but not sure if this warrants another major release.

gregbty commented 3 years ago

I resolved the formatting issues. I noticed that the array based rewrite test was failing, so I reverted the logic used for rewriting array items. This means that the feature is only supported for non-array parents. Is that fine, or would you rather not have that limitation?

chanind commented 3 years ago

As long as tests are passing it should be OK I think!

chanind commented 3 years ago

:tada: This PR is included in version 3.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Sytten commented 3 years ago

This PR broke production for fields returning arrays, I am pushing a fix soon. This is quite critical @chanind @gregbty

chanind commented 3 years ago

Ack thanks for finding this! If you push a fix and a test we'll get this merged ASAP

gregbty commented 3 years ago

Sorry about that @Sytten, looks like there were a lack of tests for nested arrays which is why it wasn't caught when I added this.

Sytten commented 3 years ago

This will all be resolved by pr #29, I added more tests but I still feel we need more to really ensure we dont break edge cases.

chanind commented 3 years ago

Sorry about that! I had naively assumed our tests were good enough to cover most cases, but clearly that was not true. Thanks so much for the quick fix for this @Sytten!