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

Use schema functor to generate custom schemas #2

Open
kettanaito opened this issue Aug 15, 2019 · 1 comment
Open

Use schema functor to generate custom schemas #2

kettanaito opened this issue Aug 15, 2019 · 1 comment

Comments

@kettanaito
Copy link
Member

kettanaito commented Aug 15, 2019

Reach Schema should come with a sensible default behavior. However, ceratin use cases may want to modify how a schema is applied. Examples of such modifications may be:

  • Custom resolver function arguments
  • Custom actual data traversal method

Specification

import { createSchemaFunctor } from 'reach-schema'

const applyCustomSchema = createSchemaFunctor({
  traverse: (tree, node) => {},
  resolver: (value) => {}
})

applyCustomSchema({
  data: ({ value }) => value !== 2
}, {
  data: 'value'
})

Call signatures to be designed

@kettanaito
Copy link
Member Author

Main motivation for this feature is to be able to create variable schemas that inherit the same behavior. The principle of the library remains the same, while certain aspects like traversal algorithm or a resolver signature vary.

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

No branches or pull requests

1 participant