apollographql / apollographql/federation

buildFederatedSchema loses resolvers argument typings

Open
#345 1 comment 4 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

inside the internal `apollo-graphql` package the following implementation of GraphQLResolverMap, prevents the GraphQLFieldResolver to have typings for the `Args`.

```typescript
import { GraphQLFieldResolver, GraphQLScalarType } from "graphql";

export interface GraphQLResolverMap {
[typeName: string]:
| {
[fieldName: string]:
| GraphQLFieldResolver
| {
requires?: string;
resolve: GraphQLFieldResolver;
};
}
| GraphQLScalarType
| {
[enumValue: string]: string | number;
};
}
```

one must mark all arg fields as optional to match the default typings of `Args` `{ [argName: string]: any }`, like:
```typescript
const resolverFn = (
_: null,
{ argField }: { argField?: string },
) => {
// implementation
};
```

Contributor guide

Open the contributing guide

Research direction

Start in the internal `apollo-graphql` package at the `GraphQLResolverMap` definition and inspect how its `GraphQLFieldResolver` types pass argument typings. Reproduce the resolver example from the issue and verify that required argument fields no longer need to be marked optional; add or update a focused TypeScript typing check if the package's existing tests provide one.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.