buildSubgraphSchema Typescript typing conflict with resolver

Hi there!

I’m integrating a federated schema in typescript and I believe there might be an issue with the typing? Unless there’s something that I’m missing. Here’s what I’m noticing:
I have a resolver for a mutation like this:

Mutation: {
    login: (parent:unknown, { email, password }: { email:string, password:string }) => {
      return someValue
    }
  }

But that mutation gives the following error:

I can fix the error above by changing the signature of login by removing the parent argument like so: login: (parent:unknown, { email, password }: { email:string, password:string })login: ({ email, password }: { email:string, password:string })
But that’s not the solution because parent is part of the arguments of the mutation. So my question is, am I doing something wrong or is this a defect with Apollo?

Note: buildFederatedSchema and buildSubgraphSchema, both have the same issue

Can you please share a reproduction via codesandbox or a repo I can clone and build locally?

Hey @trevor.scheer !
I added the minimum code required to reproduce the issue. You can clone this repo. The issue should be visible here. Here is a screenshot of the issue happening in the project that I linked:

Thanks for the quick reproduction - super helpful! It looks like it boils down to not liking the typing of your args parameter (nothing wrong with what you’re doing, TS is just seeing a mismatch and we have it incorrect). As a workaround, I was able to use graphql@16 in your reproduction to solve the issue.

I’ve opened a PR which replicates the v16 behavior and should resolve the issue for ^15.8.0 users.

https://github.com/apollographql/federation/pull/1499

1 Like

Oh, yeah, v16 fixes the issue. I had some peer dependencies issues with @apollo/gateway when I was starting this test project. It was fixed by downgrading GQL to v15. After your reply, I revised the versions in my package.json and now I can use v16.

I’m glad your PR addressed the issue in v15 though!

Thanks for your help on this :slight_smile: