Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
MPDX-8309 Send user's language to GraphQL server #1095
MPDX-8309 Send user's language to GraphQL server #1095
Changes from 3 commits
f0e3e94
6ffb744
a1c620c
73dd1ab
29daceb
b46310a
a8bb1c2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 61 in pages/_app.page.tsx
Codecov / codecov/patch
pages/_app.page.tsx#L60-L61
Check warning on line 28 in src/lib/apollo/client.ts
Codecov / codecov/patch
src/lib/apollo/client.ts#L28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the server automatically honor the user's language preference? This code looks like it uses the language preference and defaults to the accept header: https://github.com/CruGlobal/mpdx_api/blob/7eff744504fe52358a0a975cb5f36ee6b5f1e5ad/app/controllers/graphql_controller.rb#L59-L68
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading it right,
scope_request_to_locale
runs for every GraphQL request https://github.com/CruGlobal/mpdx_api/blob/7eff744504fe52358a0a975cb5f36ee6b5f1e5ad/app/controllers/graphql_controller.rb#L2There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does, but by default, GraphQL sends the
en-US
value as theAccept-Language
if it is missing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misread it. The server uses the
Accept-Language
header first and falls back to the user's preference. I feel like we should ask the server people to switch that. In the meantime, can you just setAccept-Language
to an empty string? When I do that, translated constants are coming through. I think that would be a simpler solution and it won't require the user to log out to update their language.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked for me
Check warning on line 31 in src/lib/apollo/ssrClient.ts
Codecov / codecov/patch
src/lib/apollo/ssrClient.ts#L31