Skip to content

Commit 3f2ea80

Browse files
authored
Merge pull request #108 from semi-technologies/graphql_request
Replaces graphql-client with graphql-request due to vulnerabilities
2 parents 52c2a28 + e07ebf5 commit 3f2ea80

File tree

3 files changed

+111
-77
lines changed

3 files changed

+111
-77
lines changed

connection/gqlClient.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import graphqlClient from 'graphql-client';
1+
import { GraphQLClient } from 'graphql-request'
22

33
export 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;

0 commit comments

Comments
 (0)