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

[BUG] Issue with enum type mappers using @apollo/federation buildSubgraphSchema #312

Open
tagleeson opened this issue Jul 5, 2024 · 0 comments
Assignees

Comments

@tagleeson
Copy link

Describe the bug
In v 0.10.0, enum resolvers are automatically generated, but this doesn't seem to play nice with the buildSubgraphSchema function (at least from @apollo/federation v0.38.1). Ends up with an error similar to below:

TS2345: Argument of type
{   typeDefs: DocumentNode;   resolvers: Resolvers; }
is not assignable to parameter of type
DocumentNode | (DocumentNode | GraphQLSchemaModule)[] | LegacySchemaModule
Types of property resolvers are incompatible.
Type Resolvers is not assignable to type GraphQLResolverMap<any>
Property IntegrationsConnectionType is incompatible with index signature.
Type 'EnumResolverSignature<{ ValueOne?: any; ValueTwo?: any; }, ResolverTypeWrapper<"ValueOne" | "ValueTwo">>' is not assignable to type 'GraphQLScalarType<unknown, unknown> | { [enumValue: string]: string | number; } | { [fieldName: string]: GraphQLFieldResolver<any, any, any> | { requires?: string | undefined; resolve: GraphQLFieldResolver<...>; }; }'.
Type 'EnumResolverSignature<{ ValueOne?: any; ValueTwo?: any; }, ResolverTypeWrapper<"ValueOne" | "ValueTwo">>' is not assignable to type '{ [fieldName: string]: GraphQLFieldResolver<any, any, any> | { requires?: string | undefined; resolve: GraphQLFieldResolver<any, any, any>; }; }'.
Property ValueOne is incompatible with index signature.
Type 'ResolverTypeWrapper<"ValueOne" | "ValueTwo">' is not assignable to type 'GraphQLFieldResolver<any, any, any> | { requires?: string | undefined; resolve: GraphQLFieldResolver<any, any, any>; }'.
Type 'string' is not assignable to type 'GraphQLFieldResolver<any, any, any> | { requires?: string | undefined; resolve: GraphQLFieldResolver<any, any, any>; }'

To Reproduce
Steps to reproduce the behavior:
Using a graphql schema including an enum type, eg:

type Query {
  someTypeFetch: SomeType!
}

enum SomeEnum {
  ValueOne
  ValueTwo
}

type SomeType {
  someEnum: SomeEnum!
}

Create a corresponding typescript enum:

export enum SomeEnum {
  ValueOne = "ValueOne",
  ValueTwo = "ValueTwo"
}

With a yml config (simplified, might not be 100% correct):

schema: 'schema.graphql'
generates:
  output/schema:
    preset: '@eddeee888/gcg-typescript-resolver-files'
    watchPattern: '**/*.mappers.ts'
    presetConfig:
      typesPluginsConfig:
        federation: true
        enumValues:
          SomeEnum: "./types#SomeEnum"

Removing enumValues, and playing around with adding or removing mappers doesn't seem to change the outcome

Expected behavior
Using a mapped enum works as expected

Additional context
Reverting back to 0.9.2 resolves the issue

@eddeee888 eddeee888 self-assigned this Aug 7, 2024
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

No branches or pull requests

2 participants