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): Add schema resolver converter functionality #2640

Merged
merged 1 commit into from
May 22, 2022

Conversation

daffl
Copy link
Member

@daffl daffl commented May 21, 2022

This pull request adds a converter option to schema resolvers which allow to convert existing data into a completely different format. Converters always run before validation and property resolvers.

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

@daffl daffl merged commit 26d9e05 into dove May 22, 2022
@daffl daffl deleted the schema-converter branch May 22, 2022 15:48
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