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

CLOSES #35 Quoting issue #39

Merged
merged 4 commits into from
Jul 15, 2021

Conversation

steven-collins-omega
Copy link
Member

We build GraphQL queries with Go templates. We were using a built-in
js template function for escaping arbitrary strings before using them
as JSON strings. Which almost works; it's not the intended use case
for js. We actually needed a custom template function, as implemented
here.

Most of the changes in this commit are essentially replacing js with
json where templates are defined. The meat of the commit is in
query.go and query_test.go

We build GraphQL queries with Go templates. We were using a built-in
`js` template function for escaping arbitrary strings before using them
as JSON strings. Which _almost_ works; it's not the intended use case
for `js`. We actually needed a custom template function, as implemented
here.

Most of the changes in this commit are simply replacing `js` with
`json` where templates are defined. The meat of the commit is in
`query.go`.
Rather than the approach of the previous commit of the `json` template
function doing something special when the output of Marshal is a JSON
string, by stripping the beginning and ending quotation marks, simply
don't use the quotation marks in the templates in the first place.
@steven-collins-omega steven-collins-omega merged commit fb58ff1 into IBM:main Jul 15, 2021
@steven-collins-omega steven-collins-omega deleted the quoting-issue branch July 15, 2021 16:51
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.

None yet

2 participants