File tree Expand file tree Collapse file tree 3 files changed +111
-77
lines changed Expand file tree Collapse file tree 3 files changed +111
-77
lines changed Original file line number Diff line number Diff line change 1- import graphqlClient from 'graphql-client' ;
1+ import { GraphQLClient } from 'graphql-request'
22
33export const gqlClient = ( config ) => {
44 const scheme = config . scheme
55 const host = config . host
66 const defaultHeaders = config . headers
77 return {
8+ // for backward compatibility with replaced graphql-client lib,
9+ // results are wrapped into { data: data }
810 query : ( query , headers = { } ) => {
9- var gql = graphqlClient ( {
10- url : ` ${ scheme } :// ${ host } /v1/graphql` ,
11- headers : {
12- ...defaultHeaders ,
13- ... headers ,
14- }
15- } ) ;
16- return gql . query ( query ) ;
11+ return new GraphQLClient ( ` ${ scheme } :// ${ host } /v1/graphql` , {
12+ headers : {
13+ ... defaultHeaders ,
14+ ...headers ,
15+ }
16+ } )
17+ . request ( query )
18+ . then ( data => ( { data } ) ) ;
1719 }
1820 }
1921}
2022
21- export default gqlClient ;
23+ export default gqlClient ;
You can’t perform that action at this time.
0 commit comments