Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Duplicate IResolvers definitions breaks build #470

@jbreeden-splunk

Description

@jbreeden-splunk

Description

Graphqlgen overrides the declaration of IResolvers from the graphql-tools package in the generated graphqlgen.ts file. This causes an error when you try to compose a schema from two packages that both use graphqlgen.

Each package will have a declaration like so:

// @ts-ignore
declare module 'graphql-tools' {
    interface IResolvers extends Resolvers {}
}

Where Resolvers is a unique type generated within the package itself.

Since IResolvers will be defined in both packages, with different definitions, you get the following error at build time:

TSError: ⨯ Unable to compile TypeScript:
src/generated/graphqlgen.ts(8464,15): error TS2320: Interface 'IResolvers' cannot simultaneously extend types 'Resolvers' and 'Resolvers'.
  Named property 'Mutation' of types 'Resolvers' and 'Resolvers' are not identical.
src/generated/graphqlgen.ts(8464,15): error TS2320: Interface 'IResolvers' cannot simultaneously extend types 'Resolvers' and 'Resolvers'.
  Named property 'Query' of types 'Resolvers' and 'Resolvers' are not identical.

Steps to reproduce

  • Create a graphql service, using graphqlgen
  • Create a package, also using graphqlgen, that exports an executable schema
    • This package should be built with declaration files enabled
  • Import the package into your graphqlservice
  • Configure your service to mergeSchemas when starting your service
  • Try to build the service
  • You should get the error because each package now has a conflicting IResolvers definition

Note, I'm not actually even using these types. Their presence in graphqlgen.ts appears to be enough to cause the error.

Expected results

No error is thrown

Actual results

TSError: ⨯ Unable to compile TypeScript

Versions

  • graphqlgen: 0.6.0-rc9
  • OS name and version: OSX 10.14.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions