File tree Expand file tree Collapse file tree 1 file changed +31
-4
lines changed
packages/graphql-playground-react/src/components/Playground Expand file tree Collapse file tree 1 file changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -610,16 +610,43 @@ export class GraphQLEditor extends React.PureComponent<
610
610
}
611
611
612
612
getCurl = ( ) => {
613
+ let variables
614
+ try {
615
+ variables = JSON . parse ( this . state . variables )
616
+ } catch ( e ) {
617
+ //
618
+ }
613
619
const data = JSON . stringify ( {
614
620
query : this . state . query ,
615
- variables : this . state . variables ,
621
+ variables : variables ,
616
622
operationName : this . state . operationName ,
617
623
} )
624
+ let sessionHeaders
625
+
626
+ try {
627
+ sessionHeaders = JSON . parse ( this . props . session . headers ! )
628
+ } catch ( e ) {
629
+ //
630
+ }
631
+
632
+ const headers = {
633
+ 'Accept-Encoding' : 'gzip, deflate, br' ,
634
+ 'Content-Type' : 'application/json' ,
635
+ 'Accept' : '*/*' ,
636
+ 'Connection' : 'keep-alive' ,
637
+ 'DNT' : '1' ,
638
+ 'Origin' : location . origin ||
639
+ this . props . session
640
+ . endpoint ,
641
+ ...sessionHeaders ,
642
+ }
643
+ const headersString = Object . keys ( headers ) . map ( key => {
644
+ const value = headers [ key ]
645
+ return `-H '${ key } : ${ value } '`
646
+ } ) . join ( ' ' )
618
647
return `curl '${
619
648
this . props . session . endpoint
620
- } ' -H 'Origin: ${ location . origin ||
621
- this . props . session
622
- . endpoint } ' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: */*' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '${ data } ' --compressed`
649
+ } ' ${ headersString } --data-binary '${ data } ' --compressed`
623
650
}
624
651
625
652
setQueryVariablesRef = ref => {
You can’t perform that action at this time.
0 commit comments