Skip to content

Mutator should allow rethrowing errors in "onCreate", "onUpdate" callbacks for server generated fields #109

Open
@eric-burel

Description

@eric-burel

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

When a field callback fails, the error is always caught.
However, in some scenarios, you want such an error to bubble up and fail the whole document creation.

Describe the solution you'd like

https://github.com/VulcanJS/vulcan-npm/blob/main/packages/graphql/server/resolvers/mutators.ts#L318

Describe alternatives you've considered

  • optional in a field schema, means optional from the user standpoint, eg in forms or hooks.
  • However, sometimes, you want some data to be optional from the user standpoint, but you expect the creation process to succeed server-side via callbacks
  • We would need another option, like validateCallbacks that rethrows the error. OR we could reverse the current behaviour, throw as a default, and provide a dontFailOnCallbackError flag for instance.

Additional context
This was for example used in file upload in vulcan meteor.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions