MichalLytek / MichalLytek/type-graphql
`createResolversMap` returns an incompatible type
- Dominant language
- TypeScript
- Stars
- 8.1k
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Description
**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'.
'string' index signatures are incompatible.
Type 'GraphQLScalarType | EnumResolver | ResolverOptions | ResolverObject' is not
assignable to type 'GraphQLScalarType | { [enumValue: string]: string | number; } | { [fieldName: string]:
GraphQLFieldResolver | { requires?: string | undefined; resolve?: GraphQLFieldResolver<...> | undefined; subscribe?:
GraphQLFieldResolver<...> | undefined; }; }'.
Type 'ResolverOptions' is not assignable to type 'GraphQLScalarType | { [enumValue: string]:
string | number; } | { [fieldName: string]: GraphQLFieldResolver | { requires?: string | undefined; resolve?:
GraphQLFieldResolver<...> | undefined; subscribe?: GraphQLFieldResolver<...> | undefined; }; }'.
Type 'ResolverOptions' is not assignable to type '{ [fieldName: string]: GraphQLFieldResolver | {
requires?: string | undefined; resolve?: GraphQLFieldResolver | undefined; subscribe?: GraphQLFieldResolver<...> |
undefined; }; }'.
Index signature for type 'string' is missing in type 'ResolverOptions'. [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
Contributor guide
Research direction
Start with createResolversMap and the example's helpers/buildFederatedSchema.ts, then reproduce the TypeScript error using the latest type-graphql and @apollo/subgraph versions. Done means the return value is accepted by buildSubgraphSchema without the reported resolver type incompatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100