How to use apollo-angular-link-http-common - 9 common examples

To help you get started, we’ve selected a few apollo-angular-link-http-common 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 apollographql / apollo-angular / packages / apollo-angular-link-http / src / HttpLink.ts View on Github external
const pick = (
          key: K,
          init?: Context[K] | Options[K],
        ): Context[K] | Options[K] => {
          return prioritize(context[key], this.options[key], init);
        };
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
return Math.random()
        .toString(36)
        .substr(2, 9);
    }

    const headers =
      context.headers &&
      context.headers.keys().map((k: string) => context.headers.get(k));

    const opts = JSON.stringify({
      includeQuery: context.includeQuery,
      includeExtensions: context.includeExtensions,
      headers,
    });

    return prioritize(context.uri, this.options.uri) + opts;
  }
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
return operations.map(operation => {
      const includeExtensions = prioritize(
        operation.getContext().includeExtensions,
        this.options.includeExtensions,
        false,
      );
      const includeQuery = prioritize(
        operation.getContext().includeQuery,
        this.options.includeQuery,
        true,
      );

      const body: Body = {
        operationName: operation.operationName,
        variables: operation.variables,
      };

      if (includeExtensions) {
        body.extensions = operation.extensions;
      }

      if (includeQuery) {
        body.query = print(operation.query);
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
private createOptions(operations: Operation[]): Options {
    const context: Context = operations[0].getContext();

    return {
      method: prioritize(context.method, this.options.method, defaults.method),
      uri: prioritize(context.uri, this.options.uri, defaults.uri),
      withCredentials: prioritize(
        context.withCredentials,
        this.options.withCredentials,
      ),
    };
  }
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
private createOptions(operations: Operation[]): Options {
    const context: Context = operations[0].getContext();

    return {
      method: prioritize(context.method, this.options.method, defaults.method),
      uri: prioritize(context.uri, this.options.uri, defaults.uri),
      withCredentials: prioritize(
        context.withCredentials,
        this.options.withCredentials,
      ),
    };
  }
github apollographql / apollo-angular / packages / apollo-angular-link-http / src / HttpLink.ts View on Github external
if (includeExtensions) {
          (req.body as Body).extensions = operation.extensions;
        }

        if (includeQuery) {
          (req.body as Body).query = print(operation.query);
        }

        if (context.headers) {
          req.options.headers = mergeHeaders(
            req.options.headers,
            context.headers,
          );
        }

        const sub = fetch(req, this.httpClient, extractFiles).subscribe({
          next: response => {
            operation.setContext({response});
            observer.next(response.body);
          },
          error: err => observer.error(err),
          complete: () => observer.complete(),
        });

        return () => {
          if (!sub.closed) {
            sub.unsubscribe();
          }
        };
      });
  }
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
if (typeof uri === 'function') {
          throw new Error(`Option 'uri' is a function, should be a string`);
        }

        const req: Request = {
          method,
          url: uri,
          body: body,
          options: {
            withCredentials,
            headers,
          },
        };

        const sub = fetch(req, this.httpClient, () => {
          throw new Error(
            'File upload is not available when combined with Batching',
          );
        }).subscribe({
          next: result => observer.next(result.body),
          error: err => observer.error(err),
          complete: () => observer.complete(),
        });

        return () => {
          if (!sub.closed) {
            sub.unsubscribe();
          }
        };
      });
    };
github apollographql / apollo-angular / packages / apollo-angular-link-http-batch / src / HttpBatchLink.ts View on Github external
return operations.reduce((headers: HttpHeaders, operation: Operation) => {
      return mergeHeaders(headers, operation.getContext().headers);
    }, this.options.headers);
  }
github apollographql / apollo-angular / packages / apollo-angular-link-http / src / HttpLink.ts View on Github external
withCredentials,
            useMultipart,
            headers: this.options.headers,
          },
        };

        if (includeExtensions) {
          (req.body as Body).extensions = operation.extensions;
        }

        if (includeQuery) {
          (req.body as Body).query = print(operation.query);
        }

        if (context.headers) {
          req.options.headers = mergeHeaders(
            req.options.headers,
            context.headers,
          );
        }

        const sub = fetch(req, this.httpClient, extractFiles).subscribe({
          next: response => {
            operation.setContext({response});
            observer.next(response.body);
          },
          error: err => observer.error(err),
          complete: () => observer.complete(),
        });

        return () => {
          if (!sub.closed) {

apollo-angular-link-http-common

Common logic for http links. For internal use only.

MIT
Latest version published 4 years ago

Package Health Score

66 / 100
Full package analysis