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: Add @validate directive for custom scalar validation #1847

Open
3 tasks
amitksingh1490 opened this issue May 3, 2024 · 8 comments
Open
3 tasks

feat: Add @validate directive for custom scalar validation #1847

amitksingh1490 opened this issue May 3, 2024 · 8 comments

Comments

@amitksingh1490
Copy link
Collaborator

amitksingh1490 commented May 3, 2024

Description:
Currently, Tailcall allows developers to define custom scalars. However, there's no built-in way to add validations on those custom scalars. I propose creating a @validate directive which takes js function as input and can be applied on scalars. The js function inside @validate should return either true or false. If it returns false, the user should receive a Evaluation error when an invalid value is passed into the scalar.

Expected Behavior:

  • The @validate directive should be applicable to custom scalar types.
  • The directive js function should return true for valid values and false for invalid values.
  • If the directive returns false, a Evaluation error should be thrown to indicate the issue to the user.

Tasks:

  • Implement a @validate directive that developers can use on custom scalars.
  • @Validate accepts a js function as input.
  • errors should follow the formatting guidelines of Tailcall Evaluation Errors

Example

scalar EvenNumber @validate(js: "isEven")
function isEven(num) {
	return num % 2 === 0
}
@tusharmath
Copy link
Contributor

/bounty 100

Copy link

algora-pbc bot commented May 4, 2024

💎 $100 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #1847 with your implementation plan
  2. Submit work: Create a pull request including /claim #1847 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

🙏 Thank you for contributing to tailcallhq/tailcall!
🧐 Checkout our guidelines before you get started.

Attempt Started (GMT+0) Solution
🔴 @webbdays May 4, 2024, 9:22:15 AM WIP
🟢 @mobley-trent May 7, 2024, 2:39:49 PM #1889

@tusharmath tusharmath changed the title [Draft] Feat: Add @validate directive for custom scalar validation feat: Add @validate directive for custom scalar validation May 4, 2024
@webbdays
Copy link
Contributor

webbdays commented May 4, 2024

/attempt

Algora profile Completed bounties Tech Active attempts Options
@webbdays 2 tailcallhq bounties
Python, Rust,
JavaScript & more
Cancel attempt

Copy link

algora-pbc bot commented May 5, 2024

@webbdays: Reminder that in 1 days the bounty will become up for grabs, so please submit a pull request before then 🙏

Copy link

algora-pbc bot commented May 6, 2024

The bounty is up for grabs! Everyone is welcome to /attempt #1847 🙌

@mobley-trent
Copy link
Contributor

mobley-trent commented May 7, 2024

/attempt #1847

Algora profile Completed bounties Tech Active attempts Options
@mobley-trent 2 tailcallhq bounties
Python, Rust,
Jupyter Notebook
Cancel attempt

@webbdays
Copy link
Contributor

@mobley-trent
are you still on this?

@mobley-trent
Copy link
Contributor

Feel free to pick up the issue @webbdays

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants