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

[Idea] Implement validation functionality #6

Open
bboure opened this issue Mar 1, 2021 · 0 comments
Open

[Idea] Implement validation functionality #6

bboure opened this issue Mar 1, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@bboure
Copy link
Owner

bboure commented Mar 1, 2021

AppSync/GraphQL already does some heavy lifting about validation. Field types and optionality/requirement are already handled. However, there are some times when you just need more. eg: - a string should be > n characters

  • a number has a min/max limit
  • a date cannot be in the past/future

etc.

I think it might be a good idea to implement a solution to allow a second layer of validation at the code level for deeper control. Maybe averaging a library like Joi or Yup, with possibly an option for custom implementation.

I see at least 3 things that could use validation.

  • event.arguments
  • event.source
  • the resolver output

The API might look like this:

middy(...).use(appSync({
	validate: {
 	  arguments: ...,
 	  source: ...,
 	  output: ...,
	},
}));

By default, no validation should be made.

@bboure bboure added the enhancement New feature or request label Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant