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

resolveReference no longer called correctly in latest @apollo/subgraph version #2228

Closed
1 task done
trevor-scheer opened this issue Jun 7, 2022 · 6 comments
Closed
1 task done

Comments

@trevor-scheer
Copy link
Contributor

trevor-scheer commented Jun 7, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Nest appears to depend on some non-public API within the subgraph library by calling the resolveReference functions directly. The location of this function was moved onto the extensions object in latest versions of the @apollo/subgraph library, so the usage needs to be updated here.

I'm not quite sure how users install dependencies and use the nest framework, so this may or may not be a breaking change for your library.

To see the change that was made: apollographql/federation#1747

(I'm going to fill out the rest of the required template bits with nonsense, I'm not going to provide a reproduction but maybe @NeutronScott12 can)

Other useful links:
apollographql/federation#1895

interface GraphQLObjectType {
resolveReference?: any;
}
interface GraphQLObjectTypeConfig<TSource, TContext> {
resolveReference?: any;
}

objectType.resolveReference = type.resolveReference;

And since I noticed it, transformSchema from apollo-tooling is no longer used (it lives in the federation repo now) so this comment should be updated:

// This file is copied from `apollo-tooling`. The only difference is that it has a hack to not remove federation specific properties.
// The changed lines are 31-40 and 85-87 and the original file can be found here:
// https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-graphql/src/schema/transformSchema.ts

@NeutronScott12
Copy link

NeutronScott12 commented Jun 7, 2022

Thanks for opening it here.

But it's once you install subgraph 0.4.2, it stops resolving across the services.

I tried with this example - https://github.com/nestjs/nest/tree/master/sample/31-graphql-federation-code-first - and it still didn't work.

But once I changed the version to 0.4.0, it worked again.

@kdawgwilk
Copy link
Contributor

@NeutronScott12 Did you mean subgraph 2.0? 4.0/4.2 doesn't appear to be a valid version

@NeutronScott12
Copy link

@NeutronScott12 Did you mean subgraph 2.0? 4.0/4.2 doesn't appear to be a valid version

0.4.2(forgot to add the 0), Nest doesn't work for version 2 of anything of Apollo yet.

@kamilmysliwiec
Copy link
Member

Would you like to create a PR to address this issue?

@trevor-scheer
Copy link
Contributor Author

-> #2245

@kamilmysliwiec
Copy link
Member

Thank you @trevor-scheer! Let's track this here #2245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants