Fixes a problem where persisted query string parameters are not being properly encoded
Description
JSON.stringify is used to coerce objects into string parameters. When it's used on a string, the value is quoted adding some additional, unexpected characters to the encoded url.
For example, where the parameter name: test is provided, then it is output in the url as:
Added a unit test that failed with simple key=value parameters by verifying the url passed to fetch. Test passes with small change to the runPersistedQuery function that checks the val type before using JSON.stringify(...)
Screenshots (if appropriate):
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Fixes a problem where persisted query string parameters are not being properly encoded
Description
JSON.stringify
is used to coerce objects into string parameters. When it's used on a string, the value is quoted adding some additional, unexpected characters to the encoded url.For example, where the parameter
name: test
is provided, then it is output in the url as:http://localhost/graphql/execute.json/wknd/persist-query-name%3Bname%3D%22test%22
(url encoded)http://localhost/graphql/execute.json/wknd/persist-query-name;name="test"
(unencoded) instead of:http://localhost/graphql/execute.json/wknd/persist-query-name%3Bname%3Dtest
(url encoded)http://localhost/graphql/execute.json/wknd/persist-query-name;name=test
(unencoded)Related Issue
49, #51
Motivation and Context
How Has This Been Tested?
Added a unit test that failed with simple key=value parameters by verifying the url passed to fetch. Test passes with small change to the runPersistedQuery function that checks the
val
type before usingJSON.stringify(...)
Screenshots (if appropriate):
Types of changes
Checklist: