Skip to content

Commit

Permalink
Fixes prisma-labs#34: pass query as query string parameter when reque…
Browse files Browse the repository at this point in the history
…sted with GET method
  • Loading branch information
jvelo committed Dec 20, 2019
1 parent 2e87323 commit d9156ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,18 @@ export async function getRemoteSchema(
{ status: 'ok'; schema: string } | { status: 'err'; message: string }
> {
try {
const { data, errors } = await fetch(endpoint, {
let url = endpoint;
let body: string | undefined = JSON.stringify({ query: introspectionQuery });

if (options.method === 'GET') {
endpoint = endpoint + `?query=${encodeURIComponent(introspectionQuery)}`;
body = undefined;
}

const { data, errors } = await fetch(url, {
method: options.method,
headers: options.headers,
body: JSON.stringify({ query: introspectionQuery }),
body
}).then(res => res.json())

if (errors) {
Expand Down

0 comments on commit d9156ac

Please sign in to comment.