apollographql / apollographql/federation
buildFederatedSchema loses resolvers argument typings
- 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
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