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

fix __typename not selected if already selected with alias #5963

Merged
merged 3 commits into from
Mar 11, 2024

Conversation

EmrysMyrddin
Copy link
Collaborator

Description

The TransformCompositeFields allows to transform fields, which automatically adds __typename to the selection set.

Problem is that to avoid duplicating the selection of this field, we check if it's already selected. This check is flawed because it doesn't take in account the possible alias, which leads to __typename not being selected if already present in the query with an alias.

This causes incompatibility with the response-cache plugin which rely on selecting __typename, but with a __responseCacheType alias.

Related ardatan/graphql-mesh#6272

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Further comments

A better fix would have been to do exactly what response-cache plugin is doing, always adding typename but with a uniq identifiable alias. This would simplify code and allow for result clean up. But since the usage of this transform is already spreaded and used as is, changing the assumption that a __typename is always present would break a lot of other transforms.

Copy link

changeset-bot bot commented Mar 7, 2024

🦋 Changeset detected

Latest commit: 1ea54ce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-tools/wrap Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Mar 7, 2024

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.........................: 100.00% ✓ 352      ✗ 0  
     data_received..................: 41 MB   4.1 MB/s
     data_sent......................: 151 kB  15 kB/s
     http_req_blocked...............: avg=4.05µs   min=2.1µs    med=2.62µs   max=193.72µs p(90)=3.89µs   p(95)=4.3µs   
     http_req_connecting............: avg=701ns    min=0s       med=0s       max=123.48µs p(90)=0s       p(95)=0s      
     http_req_duration..............: avg=52.65ms  min=45.36ms  med=49.3ms   max=144.69ms p(90)=56.41ms  p(95)=85.19ms 
       { expected_response:true }...: avg=52.65ms  min=45.36ms  med=49.3ms   max=144.69ms p(90)=56.41ms  p(95)=85.19ms 
     http_req_failed................: 0.00%   ✓ 0        ✗ 176
     http_req_receiving.............: avg=128.74µs min=100.82µs med=125.56µs max=417.65µs p(90)=141.32µs p(95)=148.76µs
     http_req_sending...............: avg=25.22µs  min=17.94µs  med=24.41µs  max=113.74µs p(90)=28.81µs  p(95)=32.07µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=52.49ms  min=45.23ms  med=49.15ms  max=144.29ms p(90)=56.21ms  p(95)=85.03ms 
     http_reqs......................: 176     17.58524/s
     iteration_duration.............: avg=56.83ms  min=49.03ms  med=53.61ms  max=148.76ms p(90)=61.35ms  p(95)=88.84ms 
     iterations.....................: 176     17.58524/s
     vus............................: 1       min=1      max=1
     vus_max........................: 1       min=1      max=1

Copy link
Contributor

github-actions bot commented Mar 7, 2024

💻 Website Preview

The latest changes are available as preview in: https://2c8e28c7.graphql-tools.pages.dev

Copy link
Contributor

github-actions bot commented Mar 7, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-tools/wrap 10.0.3-alpha-20240307140204-1ea54cec9dc8bab28152c73aa79192c537ee5f3c npm ↗︎ unpkg ↗︎

@ardatan ardatan merged commit 8199416 into master Mar 11, 2024
30 checks passed
@ardatan ardatan deleted the fix/composite_field_transform_aliased_typename branch March 11, 2024 10:08
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.

2 participants