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

[batch-delegate] Error paths use their batched indices #2951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mjbcopland
Copy link

@mjbcopland mjbcopland commented May 12, 2021

Description

Reproduction test case. When using an n-plus-one delegateToSchema, the result is as expected. When using batchDelegateToSchema, error paths are incorrect.

We expect the path to have index 1 as the error is for the second object, however it is the same error as at index 0 and is deduplicated in the batched request. The error returned has this deduplicated index instead of its actual index.

 FAIL  packages/batch-delegate/tests/errorPaths.test.ts
  ● preserves error path indices › using batchDelegateToSchema

    expect(received).toMatchObject(expected)

    - Expected  - 1
    + Received  + 1

    @@ -28,11 +28,11 @@
              "id": "1",
            },
            "message": "Not Found",
            "path": Array [
              "objects",
    -         1,
    +         0,
              "property",
            ],
          },
        ],
      }

      149 |
      150 |     expect(getProperty).toBeCalledTimes(1);
    > 151 |     expect(result).toMatchObject(expected);
          |                    ^
      152 |   });
      153 | });
      154 |

      at Object.<anonymous> (packages/batch-delegate/tests/errorPaths.test.ts:151:20)

Related #2950

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Adding links to sandbox or providing screenshots can help us understand more about this PR and take action on it as appropriate

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Environment:

  • OS:
  • @graphql-tools/...:
  • NodeJS:

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@changeset-bot
Copy link

changeset-bot bot commented May 12, 2021

⚠️ No Changeset found

Latest commit: d99f20b

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

@mjbcopland mjbcopland changed the title Reproduction test case [batch-delegate] Error paths use their batched indices May 12, 2021
yaacovCR added a commit that referenced this pull request Jun 1, 2021
...to use DataLoader for the actual GraphQL results, rather than the external values

This allows us to properly transduce streams.

TODO:
1. We should now be able to add the stream directive for batchDelegateToSchema.
2. Refactor error parsing, now we are relying on the onLocatedError option, but this
   is no longer necessary. Note that additional tests for batched errors are now passing
   (see #2951)
3. Bring back createBatchDelegateFn, that may be useful
4. The Receiver is now created separately for each list item, which means that the
   initialPathDepth probably does not match? This will require a separate argument to
   the Receiver constructor for adjustment
5. Bring back valuesFromResults and fix documentation, we now operate on GraphQL
   results, so should be fewer pitfalls (see #2829)
yaacovCR added a commit that referenced this pull request Jun 1, 2021
...to use DataLoader for the actual GraphQL results, rather than the external values

This allows us to properly transduce streams.

TODO:
1. We should now be able to add the stream directive for batchDelegateToSchema.
2. Refactor error parsing, now we are relying on the onLocatedError option, but this
   is no longer necessary. Note that additional tests for batched errors are now passing
   (see #2951)
3. Bring back createBatchDelegateFn, that may be useful
4. The Receiver is now created separately for each list item, which means that the
   initialPathDepth probably does not match? This will require a separate argument to
   the Receiver constructor for adjustment
5. Bring back valuesFromResults and fix documentation, we now operate on GraphQL
   results, so should be fewer pitfalls (see #2829)
@ardatan ardatan force-pushed the master branch 7 times, most recently from e1d3faf to 614c08c Compare June 29, 2021 12:28
@ardatan ardatan force-pushed the master branch 4 times, most recently from b1c69a3 to a9e6cd1 Compare July 28, 2021 12:54
yaacovCR added a commit that referenced this pull request Jul 29, 2021
yaacovCR added a commit that referenced this pull request Jul 29, 2021
and fix them by reworking batch delegation
yaacovCR added a commit that referenced this pull request Jul 29, 2021
and fix them by reworking batch delegation
yaacovCR added a commit that referenced this pull request Aug 6, 2021
use lazy query planner

add tests from #2951

and fix them by reworking batch delegation

create memoized, static buidDelegationPlan

buildDelegationPlan can be used to calculate the rounds of delegation necessary to completely merge an object given the stitching metadata stored within the schema and a given set of fieldNodes

TODO: this function could be extracted to work on the stiched schema itself rather than the extracted metadata, and might be useful as part of a graphiql-type interface
yaacovCR added a commit that referenced this pull request Aug 6, 2021
refactor externalObject internals into separate file

add tests from #2951

and fix them by reworking batch delegation

create memoized, static buidDelegationPlan

buildDelegationPlan can be used to calculate the rounds of delegation necessary to completely merge an object given the stitching metadata stored within the schema and a given set of fieldNodes

TODO: this function could be extracted to work on the stiched schema itself rather than the extracted metadata, and might be useful as part of a graphiql-type interface
@ardatan ardatan force-pushed the master branch 2 times, most recently from 3f6ec05 to 50609df Compare August 31, 2021 14:55
@vercel
Copy link

vercel bot commented Sep 13, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/theguild/graphql-tools/GeNL2PjXdSzn3dCqiZb2QZwSyn9J
✅ Preview: https://graphql-tools-git-fork-mjbcopland-issue-2950-er-459c9c-theguild.vercel.app

yaacovCR added a commit that referenced this pull request Sep 22, 2021
refactor externalObject internals into separate file

add tests from #2951

and fix them by reworking batch delegation

buildDelegationPlan can be used to calculate the rounds of delegation necessary to completely merge an object given the stitching metadata stored within the schema and a given set of fieldNodes

TODO: change buildDelegationPlan function to method on MergedTypeInfo as class? move back to stitch package?
yaacovCR added a commit that referenced this pull request Sep 23, 2021
refactor externalObject internals into separate file

add tests from #2951

and fix them by reworking batch delegation

buildDelegationPlan can be used to calculate the rounds of delegation necessary to completely merge an object given the stitching metadata stored within the schema and a given set of fieldNodes

TODO: change buildDelegationPlan function to method on MergedTypeInfo as class? move back to stitch package?
yaacovCR added a commit that referenced this pull request Sep 25, 2021
refactor externalObject internals into separate file

add tests from #2951

and fix them by reworking batch delegation

buildDelegationPlan can be used to calculate the rounds of delegation necessary to completely merge an object given the stitching metadata stored within the schema and a given set of fieldNodes

TODO: change buildDelegationPlan function to method on MergedTypeInfo as class? move back to stitch package?
@ardatan ardatan force-pushed the master branch 2 times, most recently from 4946aeb to 4be9073 Compare July 20, 2022 20:01
@theguild-bot theguild-bot mentioned this pull request Apr 23, 2023
@theguild-bot theguild-bot mentioned this pull request Oct 26, 2023
@theguild-bot theguild-bot mentioned this pull request May 23, 2024
@ardatan ardatan force-pushed the master branch 5 times, most recently from d34fb65 to b8bf584 Compare August 11, 2024 23:45
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.

1 participant