tailcall icon indicating copy to clipboard operation
tailcall copied to clipboard

bug: allow default values for input arguments.

Open laststylebender14 opened this issue 9 months ago • 5 comments

Prerequisites

  • [ ] I have checked the existing issues to ensure this is not a duplicate.
  • [ ] I am running the latest version of Tailcall.

Describe the bug

currently the default values passed to input arguments are not used to query the data.

Expected behavior

  1. In following example, we pass 1 as default value to id.
type Query {
  user(id: Int = 1): User @http(path: "/users/{{.args.id}}")
}
  1. when we make request from playground with following query then default id should be taken into account and request with default id should be made.
# client(playground) side query.
query {
 user {
     name  
  }
}
request made to upstream : http://jsonplaceholder.typicode.com/users/1

Actual behavior

  1. In following example, we pass 1 as default value to id.
type Query {
  user(id: Int = 1): User @http(path: "/users/{{.args.id}}")
}
  1. but when we make request from playground with following query then default id is not taken into account and request without id is made.
# client(playground) side query.
query {
 user {
     name  
  }
}
request made to upstream : http://jsonplaceholder.typicode.com/users/

laststylebender14 avatar May 13 '24 13:05 laststylebender14

/bounty 100$

tusharmath avatar May 13 '24 13:05 tusharmath

💎 $100 bounty • Tailcall Inc.

Steps to solve:

  1. Start working: Comment /attempt #1931 with your implementation plan
  2. Submit work: Create a pull request including /claim #1931 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. 💵 More about our bounty program.

Attempt Started (GMT+0) Solution
🟢 @ssddOnTop May 13, 2024, 1:39:44 PM WIP

algora-pbc[bot] avatar May 13 '24 13:05 algora-pbc[bot]

This is a simple fix. We need a way to specify default arguments in config. Store them in the blueprint, and then eventually while creating schema, copy them there.

tusharmath avatar May 13 '24 13:05 tusharmath

/attempt

Algora profile Completed bounties Tech Active attempts Options
@ssddOnTop 43 tailcallhq bounties
Rust, Java,
C & more
Cancel attempt

ssddOnTop avatar May 13 '24 13:05 ssddOnTop

💡 @ssddOnTop submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar May 13 '24 17:05 algora-pbc[bot]

there is an issue with async-graphql as well, I raised a PR https://github.com/async-graphql/async-graphql/pull/1527 there if it gets merged, I'll finish touchups for this issue.

ssddOnTop avatar Jun 03 '24 06:06 ssddOnTop

/tip $100 @ssddOnTop

tusharmath avatar Jul 05 '24 07:07 tusharmath

🎉🎈 @ssddOnTop has been awarded $100! 🎈🎊

algora-pbc[bot] avatar Jul 05 '24 07:07 algora-pbc[bot]