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

Avoid having extra ? at the end of request url when queryItems are empty #1729

Conversation

tranvutuan
Copy link
Contributor

@tranvutuan tranvutuan commented Mar 18, 2021

Summary

Avoid having extra ? at the end of request url when queryItems are empty

Details

Currently GraphQLGETTransformer is used to create query items for GET request endpoint. If property body of this struct is empty ( does not have value for a given key) such as:

key : "variables"
value : nil

which leads to queryItems is empty. By doing components.queryItems = queryItems, then the url ends up to have extra ? at the end like following: https://this_is_sample/abcd? instead of https://this_is_sample/abcd

Fix

Only assign queryItems to URLComponent when it is not empty

…ra ? at the end of request url + add test case
@apollo-cla
Copy link

@tranvutuan: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@designatednerd
Copy link
Contributor

@tranvutuan I can't merge this until you sign the CLA, but this looks good. Mind signing it?

@tranvutuan
Copy link
Contributor Author

@tranvutuan I can't merge this until you sign the CLA, but this looks good. Mind signing it?

@designatednerd I'm still waiting for a permission to sign the CLA from our end. I'll do right away when get approval

@designatednerd
Copy link
Contributor

Cool, thanks for the heads up.

@tranvutuan
Copy link
Contributor Author

Cool, thanks for the heads up.

Got a green light from our end and I have just signed the CLA.

@designatednerd designatednerd merged commit a52856d into apollographql:main Mar 22, 2021
@designatednerd
Copy link
Contributor

Woo hoo, thank you!

@designatednerd designatednerd added this to the Next Release milestone Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants