Skip to content

[@apollo/federation 0.21.2] types.d.ts uses GraphQLObjectType with 3 instead 2 type parameters #537

@schulzp

Description

@schulzp

Hi! I just added @apollo/federation 0.21.2 as a dependency in my project and get the following TS error:

node_modules/@apollo/federation/dist/types.d.ts:3:35 - error TS2707: Generic type 'GraphQLObjectType<TSource, TContext>' requires between 0 and 2 type arguments.

3 export declare const ServiceType: GraphQLObjectType<any, any, {
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4     [key: string]: any;
  ~~~~~~~~~~~~~~~~~~~~~~~
5 }>;
  ~~

I checked out @apollo/federation master and ran npm run compile with an additional compiler option "declaration": true in tsconfig.build.json an this results in a correct dist/types.d.ts:

import { GraphQLFieldConfig, GraphQLUnionType, GraphQLObjectType, GraphQLScalarType, GraphQLType, GraphQLNamedType, GraphQLResolveInfo } from 'graphql';
export declare const EntityType: GraphQLUnionType;
export declare const ServiceType: GraphQLObjectType<any, any>; // <-- ONLY 2 TYPE PARAMETERS
export declare const AnyType: GraphQLScalarType;
export declare type GraphQLReferenceResolver<TContext> = (reference: object, context: TContext, info: GraphQLResolveInfo) => any;
declare module 'graphql/type/definition' {
    interface GraphQLObjectType {
        resolveReference?: GraphQLReferenceResolver<any>;
    }
    interface GraphQLObjectTypeConfig<TSource, TContext> {
        resolveReference?: GraphQLReferenceResolver<TContext>;
    }
}
export declare const entitiesField: GraphQLFieldConfig<any, any>;
export declare const serviceField: GraphQLFieldConfig<any, any>;
export declare const federationTypes: GraphQLNamedType[];
export declare function isFederationType(type: GraphQLType): boolean;
//# sourceMappingURL=types.d.ts.map

Other Dependencies in the Project

"typescript": "^4.2.2",
"graphql": "^15.5.0",
"apollo-server-core": "^2.21.0",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions