Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetcher - probably bug? bad doc? #798

Closed
cavaller opened this issue May 22, 2018 · 1 comment
Closed

fetcher - probably bug? bad doc? #798

cavaller opened this issue May 22, 2018 · 1 comment

Comments

@cavaller
Copy link

cavaller commented May 22, 2018

Literally I just copied an example from your documentation and It does not work. Really? Why?

HTTP Response

{ errors:
   [ { message: 'Error parsing GraphQL request: error decoding JSON. This likely means that the GraphQL request was malformatted.: json: cannot unmarshal object into Go struct field SerializedQuery.query of type string' } ] }
import fetch from 'node-fetch';
import { introspectSchema, makeRemoteExecutableSchema, } from 'graphql-tools';

const fetcher = async ({ context, operationName, query, variables, }) => {
  const $ = (await fetch('http://api.githunt.com/graphql', {
    body: JSON.stringify({ operationName, query, variables, }),
    headers: {
      'Content-Type': 'application/json',
    },
    method: 'POST',
  }));

  const json = (await $.json());

  console.log(json);

  return json;
};

(async () => {
  try {
    const schema = makeRemoteExecutableSchema({
      fetcher,
      schema: (await introspectSchema(fetcher)),
    });

    console.log(schema);
  } catch (e) {
    console.log(e);
  }
})();
@hwillson
Copy link
Contributor

hwillson commented Sep 7, 2018

This was addressed by #933. Thanks!

@hwillson hwillson closed this as completed Sep 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants