ardatan / graphql-tools

:wrench: Utility library for GraphQL to build, stitch and mock GraphQL schemas in the SDL-first approach
https://www.graphql-tools.com
MIT License
5.35k stars 818 forks source link

Fix aliased shared root fields #6619

Closed kroupacz closed 3 weeks ago

kroupacz commented 4 weeks ago

Description

This PR includes failing tests for issue #6613 - Aliased fields cannot be resolved in federated query Details can be found in https://github.com/ardatan/graphql-tools/issues/6613.

Fixes #6613

Test Environment:

changeset-bot[bot] commented 4 weeks ago

🦋 Changeset detected

Latest commit: fed7cea3ebb868d037d2115c3acef1e4529d3e39

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

This PR includes changesets to release 12 packages | Name | Type | | ----------------------------------- | ----- | | @graphql-tools/delegate | Minor | | @graphql-tools/federation | Patch | | @graphql-tools/batch-delegate | Patch | | @graphql-tools/links | Patch | | @graphql-tools/stitch | Patch | | @graphql-tools/stitching-directives | Patch | | @graphql-tools/wrap | Patch | | federation-benchmark | Patch | | @graphql-tools/url-loader | Patch | | @graphql-tools/executor-envelop | Patch | | @graphql-tools/prisma-loader | Patch | | @graphql-tools/executor-yoga | 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

kroupacz commented 4 weeks ago

I am not sure whats wrong with imports from @apollo/gateway, but tests runs ok locally.

    TypeError: Cannot read properties of undefined (reading 'QUERY')

      2 | import { GraphQLSchema } from 'graphql';
      3 | import { createYoga } from 'graphql-yoga';
    > 4 | import { ApolloGateway, IntrospectAndCompose } from '@apollo/gateway';
        | ^
kroupacz commented 4 weeks ago

Hello @ardatan, here you can find failing tests for issues https://github.com/ardatan/graphql-tools/issues/6613 and https://github.com/ardatan/graphql-tools/issues/6614. Here https://github.com/ardatan/graphql-tools/pull/6620 is PR with fix for issue https://github.com/ardatan/graphql-tools/issues/6614.

Thank you in advance for your help and cooperation. Tomáš Kroupa

ardatan commented 3 weeks ago

Thanks for creating the PRs for the issues and fixes. They are really helpful. Do you think we could re-organize it in the following way?

So it'd be easier for us to distinguish the issues.

If you don't have time to do that, we can tackle it soon.

ardatan commented 3 weeks ago

Tests are passing somehow. Maybe you missed something in the tests.

kroupacz commented 3 weeks ago

@ardatan Yes, because this test tests that it really fails... 😄

  expect(res.data.errors).toMatchObject([
    {
      message: 'Cannot return null for non-nullable field TestNestedField.subgraph2.',
      path: ['testNestedField', 'testUserAlias'],
    },
  ]);
ardatan commented 3 weeks ago

Hahaha ok :D So it succeeds with a failure :P

ardatan commented 3 weeks ago

Thank you so much for the reproduction! I pushed the fix, I'll merge and release.