n1ru4l / envelop

Envelop is a lightweight library allowing developers to easily develop, share, collaborate and extend their GraphQL execution layer. Envelop is the missing GraphQL plugin system.
https://envelop.dev
MIT License
771 stars 119 forks source link

[useResponseCache] Ignore specfic schemaCoordinates for IdFields which are not the root of a subgraph #2249

Open Kendalor opened 1 month ago

Kendalor commented 1 month ago

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Description

Add a new optionalList of schemaCoordinates to the useResponseCacheParamters, which is used to exclude fields on specific objects in the mapSchema step.

Fixes #2247

Type of change

Please delete options that are not relevant.

Screenshots/Sandbox (if appropriate/relevant):

N/A

How Has This Been Tested?

Testet fix first on our case and environment by maintaining a parallel instance of this plugin. Further added Unit tests to first reproduce the Issue and proof the fix works.

Test Environment:

Checklist:

Further comments

N/A

changeset-bot[bot] commented 1 month ago

⚠️ No Changeset found

Latest commit: 45271af22e7b8f0eab2b4f9fde7d60f1220a22ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Kendalor commented 1 month ago

@ardatan is anythign missing ? Should the changeset be created by me ?

ardatan commented 1 month ago

@EmrysMyrddin Could you review?

EmrysMyrddin commented 3 weeks ago

Hi, I'm not entirely against this feature, but I'm afraid we are introducing it to workaround an actual bug. I'm not sure to entirely understand what is happening here. We should probably first investigate why the plugin behave like this.

Kendalor commented 2 weeks ago

@EmrysMyrddin how would you suggest to move forward ? From my expierience/debugging suggestion the plugin identifies every object with an "id" field (configurable) as a cachable entity from a subgraph. If Subgraph A returns a value containing a field with an "id", the plugin seems to remove this part of the resonse while stitching the response together from a non existing subgraph B. Therefore setting the field to null.