Closed amitksingh1490 closed 3 weeks ago
/bounty 50$
/attempt #2468
with your implementation plan/claim #2468
in the PR body to claim the bounty🙏 Thank you for contributing to tailcallhq/tailcall! 🧐 Checkout our guidelines before you get started. 💵 More about our bounty program.
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @bnchi | Jul 19, 2024, 12:22:29 PM | WIP |
Very easy fix, checkout this PR https://github.com/tailcallhq/tailcall/pull/2470
/attempt
/attempt #2468
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@bnchi | 3 tailcallhq bounties | TypeScript, Rust, HTML & more |
Cancel attempt |
@ssddOnTop go ahead
Here are some steps and pointers to help you get started on resolving this issue:
Update Directive Parsing Logic:
skipNull
option.skipNull
is false
.Modify Query Parameter Handling:
skipNull
flag.skipNull
is true
and the parameter value is null
, skip adding that parameter to the query string.Update Tests:
skipNull: true
are correctly skipped when their values are null
.skipNull
is not specified or is false
.Directive Parsing Logic:
Query Parameter Handling:
skipNull
.Tests:
/tests/execution/test-directives-undef-null-fields.md
: This file contains tests related to handling undefined and null fields in directives. Update this file to include tests for skipNull
./tests/http/config/simple.graphql
: This file defines a GraphQL schema with HTTP directives. Add test cases here to ensure the new skipNull
functionality works as expected./tests/execution/nullable-arg-query.md
: This file contains tests for nullable arguments in queries. Ensure that the new skipNull
functionality is covered here as well.Here is an example of how you might modify the query parameter handling logic:
function constructQueryParams(params) {
const queryParams = [];
for (const param of params) {
const { key, value, skipNull } = param;
if (skipNull && value === null) {
continue;
}
queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
}
return queryParams.join('&');
}
Security:
Stability:
Potential Bugs:
undefined
instead of null
. Ensure that the logic correctly differentiates between the two.I think skipNull
is a bit to specific. Ideally, we would want to skip on various values for eg: "Skip with value is equal to something" etc.
The current implementation of dispatching query params even when there are no values assigned works for most usecases.
Feature Request
Summary
The current GraphQL schema allows for HTTP requests to be configured via the
@http
directive. However, there is a need to support skipping null query parameters to avoid sending unnecessary or invalid data in requests.After https://github.com/tailcallhq/tailcall/issues/2467 the default behaviour will not skip the null params
Example
Consider the following GraphQL type definition:
In the above example, if
{{.value.authorID}}
resolves to null, theauthor_ids[]
parameter would be skipped entirely in the HTTP request.skipNull: true when specified in query params will skip the param whole value is null the default value of this argument is false