Skip to content

Commit

Permalink
Fixing "Invalid or incomplete schema" (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
offbeatful authored Dec 17, 2020
1 parent 6f883f2 commit 85eb8d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions app/dociql/fetch-schema.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const graphql = require('graphql')
const { getIntrospectionQuery, buildClientSchema } = require('graphql')
const request = require("sync-request")

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

module.exports = function (graphUrl, authHeader) {

module.exports = function (graphUrl, authHeader) {
const requestBody = {
operationName: "IntrospectionQuery",
query: graphql.introspectionQuery
query: getIntrospectionQuery()
};

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

const introspectionResponse = JSON.parse(responseBody);
const introspectionResponse = JSON.parse(responseBody);

const graphQLSchema = buildClientSchema(introspectionResponse.data);
const jsonSchema = converter.fromIntrospectionQuery(introspectionResponse.data);
const graphQLSchema = graphql.buildClientSchema(introspectionResponse.data, { assumeValid: true});

return {
jsonSchema,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dociql",
"version": "1.1.2",
"version": "1.1.3",
"description": "Generate beautiful static API documentation from GraphQL Schema",
"preferGlobal": true,
"bin": {
Expand Down

0 comments on commit 85eb8d8

Please sign in to comment.