-
Notifications
You must be signed in to change notification settings - Fork 2.3k
make post default gql method #7713
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,7 +111,7 @@ const NewRequest = ({ collectionUid, item, isEphemeral, onClose }) => { | |
| filename: '', | ||
| requestType: getRequestType(collectionPresets), | ||
| requestUrl: collectionPresets.requestUrl || '', | ||
| requestMethod: 'GET', | ||
| requestMethod: getRequestType(collectionPresets) === 'graphql-request' ? 'POST' : 'GET', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
| curlCommand: '' | ||
| }, | ||
| validationSchema: Yup.object({ | ||
|
|
@@ -343,7 +343,10 @@ const NewRequest = ({ collectionUid, item, isEphemeral, onClose }) => { | |
| name="requestType" | ||
| value="http-request" | ||
| checked={formik.values.requestType === 'http-request'} | ||
| onChange={formik.handleChange} | ||
| onChange={(e) => { | ||
| formik.handleChange(e); | ||
| formik.setFieldValue('requestMethod', 'GET'); | ||
| }} | ||
| data-testid="http-request" | ||
| /> | ||
| <label htmlFor="http-request" className="ml-1 cursor-pointer select-none"> | ||
|
|
@@ -374,7 +377,10 @@ const NewRequest = ({ collectionUid, item, isEphemeral, onClose }) => { | |
| name="requestType" | ||
| value="grpc-request" | ||
| checked={formik.values.requestType === 'grpc-request'} | ||
| onChange={formik.handleChange} | ||
| onChange={(e) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug (Major): The onChange={formik.handleChange}This means when a user starts with the default Note: the actual issue is on line 362 (outside any diff hunk) — attached to this added block for visibility. Suggested fix (apply to the graphql radio on line ~362): onChange={(e) => {
formik.handleChange(e);
formik.setFieldValue('requestMethod', 'POST');
}} |
||
| formik.handleChange(e); | ||
| formik.setFieldValue('requestMethod', 'GET'); | ||
| }} | ||
| data-testid="grpc-request" | ||
| /> | ||
| <label htmlFor="grpc-request" className="ml-1 cursor-pointer select-none"> | ||
|
|
@@ -389,7 +395,10 @@ const NewRequest = ({ collectionUid, item, isEphemeral, onClose }) => { | |
| name="requestType" | ||
| value="ws-request" | ||
| checked={formik.values.requestType === 'ws-request'} | ||
| onChange={formik.handleChange} | ||
| onChange={(e) => { | ||
| formik.handleChange(e); | ||
| formik.setFieldValue('requestMethod', 'ws'); | ||
| }} | ||
| data-testid="ws-request" | ||
| /> | ||
| <label htmlFor="ws-request" className="ml-1 cursor-pointer select-none"> | ||
|
|
||
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.
Bug (Minor): This ternary only handles the
graphql-requestpreset. If a collection haspresets.requestType === 'ws',getRequestTypereturns'ws-request', butrequestMethodis initialized to'GET'. That value is then passed through tonewWsRequestinonSubmit(see line 176), producing a WebSocket request whose method isGETinstead ofws— the same mismatch the new radioonChangehandler forws-requestis trying to prevent when the user switches types manually.Suggested fix:
(
grpc-requestdoes not passrequestMethodtonewGrpcRequest, so it does not need special handling, but hoistingdefaultRequestTypealso removes the double call flagged in the nit below.)