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

Cannot override Apollo Server's default field resolvers #2326

Open
darkbasic opened this issue Mar 21, 2023 · 1 comment · May be fixed by #2327
Open

Cannot override Apollo Server's default field resolvers #2326

darkbasic opened this issue Mar 21, 2023 · 1 comment · May be fixed by #2327

Comments

@darkbasic
Copy link
Contributor

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.

@darkbasic darkbasic linked a pull request Mar 21, 2023 that will close this issue
9 tasks
@darkbasic
Copy link
Contributor Author

createSchemaForApollo won't be supported anymore in 3.0 and fieldResolver can be emulated applying a custom directive in schemaBuilder, so I think this can be closed.

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

Successfully merging a pull request may close this issue.

1 participant