How to use the apollo-server-env.fetch function in apollo-server-env

To help you get started, we’ve selected a few apollo-server-env examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hanpama / girin / packages / framework / src / __tests__ / testenv.ts View on Github external
export async function query(doc: string, headers = {}): Promise<{ data: any, errors: any }> {
  const res = await fetch(url, {
    method: 'POST',
    headers: Object.assign({ 'Content-Type': 'application/json' }, headers),
    body: JSON.stringify({ query: doc }),
  });
  return res.json();
}
github apollographql / apollo-server / packages / apollo-engine-reporting / src / agent.ts View on Github external
async () => {
        const curResponse = await fetch(endpointUrl, {
          method: 'POST',
          headers: {
            'user-agent': 'apollo-engine-reporting',
            'x-api-key': this.apiKey,
            'content-encoding': 'gzip',
          },
          body: compressed,
          agent: this.options.requestAgent,
        });

        if (curResponse.status >= 500 && curResponse.status < 600) {
          throw new Error(
            `HTTP status ${curResponse.status}, ${(await curResponse.text()) ||
              '(no body)'}`,
          );
        } else {

apollo-server-env

This package is used internally by Apollo Server and not meant to be consumed directly.

MIT
Latest version published 3 years ago

Package Health Score

72 / 100
Full package analysis