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

feat(schema): Allow resolvers to validate a schema #2465

Merged
merged 1 commit into from Oct 6, 2021
Merged

Conversation

daffl
Copy link
Member

@daffl daffl commented Oct 6, 2021

This pull request allows to pass a schema to a resolver and if it should also run validation before or after resolving the data:

const userBeforeResolver = resolve<User, typeof context>({
  schema: userSchema,
  validate: 'before',
  properties: {
    name: async (_name, user) => `${user.firstName} ${user.lastName}`
  }
});

This could be done with separate validation and resolver hooks (and still can) but this way makes things more readable in a generated application since resolving and validation usually happen at about the same time.

@daffl daffl merged commit 7d9590b into dove Oct 6, 2021
@daffl daffl deleted the validate-resolver branch October 6, 2021 04:58
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 this pull request may close these issues.

None yet

1 participant