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

fix: handle Accept header #1789

Closed
wants to merge 3 commits into from
Closed

Conversation

webbdays
Copy link
Contributor

@webbdays webbdays commented Apr 24, 2024

Summary:

  1. Accept header handling

Issue Reference(s):
#1766

Build & Testing:

  • [yes ] I ran cargo test successfully.
  • I have run ./lint.sh --mode=fix to fix all linting issues raised by ./lint.sh --mode=check.

Checklist:

  • I have added relevant unit & integration tests.
  • I have updated the documentation accordingly.
  • [ yes] I have performed a self-review of my code.
  • [ yes] PR follows the naming convention of <type>(<optional scope>): <title>

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 24, 2024
Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 77.27273% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 86.86%. Comparing base (77508ee) to head (8747347).
Report is 63 commits behind head on main.

Files Patch % Lines
src/http/request_handler.rs 76.74% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1789      +/-   ##
==========================================
- Coverage   86.88%   86.86%   -0.03%     
==========================================
  Files         155      155              
  Lines       15581    15625      +44     
==========================================
+ Hits        13538    13572      +34     
- Misses       2043     2053      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -43,6 +43,8 @@ type Query {
```yml @test
- method: POST
url: http://localhost:8080/graphql
headers:
Accept: application/graphql-response+json
Copy link
Contributor

@tusharmath tusharmath Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logic into execution spec so that by default we make the request with headers and don't need to modify all the tess.

Copy link
Contributor Author

@webbdays webbdays Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accept there are changes in many tests files.
Realistically, headers comes form request which we define in tests files. That should be the source of truth.
Also it will be the problem for us to write tests for non compliance.
the non compliance tests i wrote fails.
@tusharmath

@tusharmath tusharmath changed the title feat: (GraphQL over HTTP) "Accept" header handling fix: handle "Accept" header handling Apr 25, 2024
@tusharmath tusharmath changed the title fix: handle "Accept" header handling fix: handle Accept header Apr 25, 2024
@tusharmath tusharmath marked this pull request as draft April 25, 2024 13:35
let count = req
.headers()
.get("Accept")
.unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not do unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

let error_message = "Unsupported 'Accept' Header value in the request, required 'application/graphql-response+json'";

// enforce this only on/after 1/1/2025, just warn until then.
if NaiveDate::from_ymd_opt(2025, 1, 1) <= Some(Local::now().date_naive()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the date check required?

Copy link
Contributor Author

@webbdays webbdays Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to draft, that requirement is must after that date.
so checking date.
But if we want to enforce that spec right from now, then not needed.
I am checking date to maintain compatibility with legacy applications and give some time for them to adopt.(according to spec.)

}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this header check in a separate function.

Copy link
Contributor Author

@webbdays webbdays Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. i also thought of that.
what about creating separate module to house all the logic to check spec.
like module: graphql_over_http ?
@tusharmath

Copy link

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Apr 27, 2024
@github-actions github-actions bot added type: fix Iterations on existing features or infrastructure. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels Apr 28, 2024
Copy link

github-actions bot commented May 1, 2024

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels May 1, 2024
Copy link

github-actions bot commented May 3, 2024

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label May 3, 2024
@tusharmath
Copy link
Contributor

@webbdays Whenever the PR is ready please mark it as ready to review. I think I missed your comments here.

@github-actions github-actions bot removed the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label May 4, 2024
Copy link

github-actions bot commented May 6, 2024

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. and removed state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. labels May 6, 2024
Copy link

github-actions bot commented May 8, 2024

Action required: PR inactive for 2 days.
Status update or closure in 5 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label May 8, 2024
Copy link

PR closed after 5 days of inactivity.

@github-actions github-actions bot closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. type: feature Brand new functionality, features, pages, workflows, endpoints, etc. type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants