Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/elm-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down