diff --git a/src/elm-ast.ts b/src/elm-ast.ts index b644d12..a5ce620 100644 --- a/src/elm-ast.ts +++ b/src/elm-ast.ts @@ -129,7 +129,7 @@ export function typeToString(ty: ElmType, level: number, isField?: boolean): str ty.fields.map(f => fieldToString(f, level + 1)).join(`${indent}, `) + `${indent}}`; } else { - throw new Error('unexpected type: ' + ty.constructor.name + ' ' + JSON.stringify(ty)); + console.error('unexpected type: ' + JSON.stringify(ty)); } } diff --git a/src/main.ts b/src/main.ts index 7d30a69..97c9181 100644 --- a/src/main.ts +++ b/src/main.ts @@ -58,11 +58,11 @@ if (options.init) { config = elmPackageJson.graphql; if (options.schema) { - elmPackageJson.schema = options.schema; + elmPackageJson.graphql.schema = options.schema; } if (options.method) { - elmPackageJson.method = options.method; + elmPackageJson.graphql.method = options.method; } // check that the endpoint works @@ -86,12 +86,12 @@ let verb = config.method || 'GET'; let endpointUrl = config.endpoint; performIntrospectionQuery(body => { - let result = JSON.parse(body); + let result = body; let schema = buildClientSchema(result.data); processFiles(schema); }); -function performIntrospectionQuery(callback: (body: string) => void) { +function performIntrospectionQuery(callback: (body: any) => void) { // introspection query let introspectionUrl = config.schema || config.endpoint; if (!introspectionUrl) { @@ -110,7 +110,8 @@ function performIntrospectionQuery(callback: (body: string) => void) { : { url: introspectionUrl, method, headers: [{ 'Content-Type': 'application/json' }], - body: JSON.stringify({ query: introspectionQuery }) + json: true, + body: { query: introspectionQuery } }; request(reqOpts, function (err, res, body) {