Added handling of graphql body mode in all codegens#120
Merged
Conversation
umeshp7
reviewed
Nov 7, 2019
Comment on lines
+52
to
+57
| try { | ||
| graphqlVariables = JSON.parse(requestBody.graphql.variables); | ||
| } | ||
| catch (e) { | ||
| graphqlVariables = {}; | ||
| } |
Member
Author
There was a problem hiding this comment.
To catch the error from JSON parsing. Just sending an empty object for variables. Not to send any undefined value or something.
…ent for graphql body requests
…rt to use JSON.stringify in the snippet generated itself
…use JSON.stringify in the snippet generated itself
abhijitkane
reviewed
Nov 12, 2019
| snippet += 'client.FollowRedirects = false;\n'; | ||
| } | ||
| snippet += `var request = new RestRequest(${isUnSupportedMethod ? '' : ('Method.' + request.method)});\n`; | ||
| if (request.body && request.body.mode === 'graphql' && !request.headers.has('Content-Type')) { |
Member
There was a problem hiding this comment.
is request.headers case-insensitive?
Member
Author
There was a problem hiding this comment.
yes. content-type or Content-Type, both the cases it returns the same
umeshp7
reviewed
Nov 13, 2019
umeshp7
approved these changes
Nov 15, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In the request body, the graphql object is comprised of two strings, namely
queryandvariables.. We will manually stringify it as one JSON object and then send it as raw body.JSON.stringify({ query: query, variables: variables})Need to discuss how this can be tested. Do we write unit tests in all the codegens stating whether the correct part of code is added in the generated snippet, or add a newman test in the basic collection? If we decide to go with the newman test, what graphql server will be used for the sample request?