graphql-hive / graphql-hive/graphql-modules

Cannot override Apollo Server's default field resolvers

Open
#2,326 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
113
Avg merge
3h 36m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**

Because of the way how `createSchemaForApollo` works if you want to override Apollo Server's default field resolvers you can't do so in Apollo Schema options.

**Describe the solution you'd like**

Instead the easiest way to achieve the same result would be to pass your custom `fieldResolver` directly to the graphql `execute` function, which is called by `createSchemaForApollo`.

**Describe alternatives you've considered**

**Additional context**

My use case is very simple: a legacy application that mixes database entities managed directly by the ORM with GraphQL helpers that aim to reduce the load down the graph. Whenever makes sense to return these helpers the return type is an object/array with the entity and the helpers, otherwise it's just the Entity. The custom fieldResolver function looks at the type: if it's an entity it returns the default fieldResolver function, otherwise it looks for the fieldName in the `info` object and decides if to call the default fieldResolver function on the entity or on the helpers.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.