Skip to content

createResolversMap returns an incompatible type #1768

@rosscooperman

Description

@rosscooperman

Describe the Bug
Following the example from https://github.com/MichalLytek/type-graphql/tree/v2.0.0-rc.2/examples/apollo-federation-2. It seems that the return type of createResolversMap (ResolversMap) is not compatible with the current version of buildSubgraphSchema from @apollo/subgraph. Full typescript error is:

Diagnostics:
1. Argument of type '{ typeDefs: DocumentNode; resolvers: ResolversMap; }' is not assignable to parameter of type 'DocumentNode |
(DocumentNode | GraphQLSchemaModule)[] | LegacySchemaModule'.
     Types of property 'resolvers' are incompatible.
       Type 'ResolversMap' is not assignable to type 'GraphQLResolverMap<unknown>'.
         'string' index signatures are incompatible.
           Type 'GraphQLScalarType<unknown, unknown> | EnumResolver | ResolverOptions<any, any> | ResolverObject<any, any>' is not
assignable to type 'GraphQLScalarType<unknown, unknown> | { [enumValue: string]: string | number; } | { [fieldName: string]:
GraphQLFieldResolver<any, unknown> | { requires?: string | undefined; resolve?: GraphQLFieldResolver<...> | undefined; subscribe?:
GraphQLFieldResolver<...> | undefined; }; }'.
             Type 'ResolverOptions<any, any>' is not assignable to type 'GraphQLScalarType<unknown, unknown> | { [enumValue: string]:
string | number; } | { [fieldName: string]: GraphQLFieldResolver<any, unknown> | { requires?: string | undefined; resolve?:
GraphQLFieldResolver<...> | undefined; subscribe?: GraphQLFieldResolver<...> | undefined; }; }'.
               Type 'ResolverOptions<any, any>' is not assignable to type '{ [fieldName: string]: GraphQLFieldResolver<any, unknown> | {
requires?: string | undefined; resolve?: GraphQLFieldResolver<any, unknown> | undefined; subscribe?: GraphQLFieldResolver<...> |
undefined; }; }'.
                 Index signature for type 'string' is missing in type 'ResolverOptions<any, any>'. [2345]

To Reproduce
Attempt to build a schema as in https://github.com/MichalLytek/type-graphql/blob/v2.0.0-rc.2/examples/apollo-federation-2/helpers/buildFederatedSchema.ts with the latest type-graphql and @apollo/subgraph.

Expected Behavior
Return value of createResolversMap should be compatible with buildSubgraphSchema.

Environment (please complete the following information):

  • OS: MacOS 15.0.1
  • Node 20.12.2
  • Package version 2.0.0-rc.2
  • TypeScript version 5.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions