Skip to content

Comments

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

Merged
daffl merged 1 commit intodovefrom
validate-resolver
Oct 6, 2021
Merged

feat(schema): Allow resolvers to validate a schema#2465
daffl merged 1 commit intodovefrom
validate-resolver

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.

1 participant