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(deps): move apollo-server-core to peer dependencies #1277

Closed
wants to merge 1 commit into from

Conversation

roderik
Copy link

@roderik roderik commented Dec 8, 2020

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Since 7.8.0 (#1104) there is the option to get the Apollo Server from the app. This is used in e2e tests to be able to create an apollo test client like so

  beforeAll(async () => {
    const moduleRef = await Test.createTestingModule({
      imports: [...],
    }).compile();

    app = moduleRef.createNestApplication();
    await app.init();

    const apolloServer = getApolloServer(app);
    apolloClient = createTestClient(apolloServer);
  });

Unfortunately, this breaks typescript compilation because apollo-server-express, @nestjs/graphql > @apollo/gateway and @nestjs/graphql >apollo-server-testing depend on apollo-server-core@2.19.0

This results in a mismatch between versions:

tests/users.e2e-spec.ts(45,37): error TS2345: Argument of type 'import("/Users/roderik/Development/bpaas-launchpad/node_modules/@nestjs/graphql/node_modules/apollo-server-core/dist/ApolloServer").ApolloServerBase' is not assignable to parameter of type 'import("/Users/roderik/Development/bpaas-launchpad/node_modules/apollo-server-core/dist/ApolloServer").ApolloServerBase'.
  Type 'ApolloServerBase' is missing the following properties from type 'ApolloServerBase': apolloConfig, serverlessFramework

Issue Number: N/A

What is the new behavior?

By moving the apollo-server-core to the peer dependencies, we can bypass this.

Workaround

When using yarn, add the following to your package.json

  "resolutions": {
    "apollo-server-core": "2.19.0"
  },

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

The issue would also (temporarily) be solved when #1118 is merged, but any future update of graphql packages will resurface this issue.

PiDelport added a commit to registreerocks/registree-core that referenced this pull request Feb 8, 2021
…16.1 → 2.19.2

This also manually overrides the resolution for @nestjs/graphql's hard
dependency on 2.16.1, which is pending update / fixing here:

* nestjs/graphql#1277

Invocation (for reference):

yarn set resolution --save 'apollo-server-core@npm:2.16.1' '^2.19.2'
PiDelport added a commit to registreerocks/registree-core that referenced this pull request Feb 9, 2021
…16.1 → 2.19.2

This also manually overrides the resolution for @nestjs/graphql's hard
dependency on 2.16.1, which is pending update / fixing here:

* nestjs/graphql#1277

Invocation (for reference):

yarn set resolution --save 'apollo-server-core@npm:2.16.1' '^2.19.2'
@uptownhr
Copy link

Are you able to see the failing reason for the build?

@remithomas
Copy link

I agree with @roderik apollo-server-coreshould be a peer dependency. I got the same issue with latest graphql-upload

@kamilmysliwiec
Copy link
Member

This has been fixed in the latest release

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.

None yet

4 participants