Skip to content

Commit 85eb8d8

Browse files
authored
Fixing "Invalid or incomplete schema" (#16)
1 parent 6f883f2 commit 85eb8d8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

app/dociql/fetch-schema.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
const graphql = require('graphql')
1+
const { getIntrospectionQuery, buildClientSchema } = require('graphql')
22
const request = require("sync-request")
33

44
const converter = require('graphql-2-json-schema');
55

6-
module.exports = function (graphUrl, authHeader) {
7-
6+
module.exports = function (graphUrl, authHeader) {
87
const requestBody = {
98
operationName: "IntrospectionQuery",
10-
query: graphql.introspectionQuery
9+
query: getIntrospectionQuery()
1110
};
1211

1312
const headers = authHeader ? Object.fromEntries([authHeader.split(":")]) : {};
@@ -17,10 +16,10 @@ module.exports = function (graphUrl, authHeader) {
1716
json: requestBody
1817
}).getBody('utf8');
1918

20-
const introspectionResponse = JSON.parse(responseBody);
19+
const introspectionResponse = JSON.parse(responseBody);
2120

21+
const graphQLSchema = buildClientSchema(introspectionResponse.data);
2222
const jsonSchema = converter.fromIntrospectionQuery(introspectionResponse.data);
23-
const graphQLSchema = graphql.buildClientSchema(introspectionResponse.data, { assumeValid: true});
2423

2524
return {
2625
jsonSchema,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dociql",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Generate beautiful static API documentation from GraphQL Schema",
55
"preferGlobal": true,
66
"bin": {

0 commit comments

Comments
 (0)