How to use the apollo-link-http-common.parseAndCheckHttpResponse function in apollo-link-http-common

To help you get started, we’ve selected a few apollo-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 bytewitchcraft / apollo-absinthe-upload-link / src / index.js View on Github external
return new Observable(observer => {
            fetch(uri, options)
              .then(response => {
                operation.setContext({ response })
                return response
              })
              .then(parseAndCheckHttpResponse(operation))
              .then(result => {
                // we have data and can send it to back up the link chain
                observer.next(result)
                observer.complete()
                return result
              })
              .catch(err => {
                if (err.result && err.result.errors && err.result.data) {
                  observer.next(err.result)
                }
                observer.error(err)
              })
          })
        } else {
github apollographql / apollo-link / packages / apollo-link-batch-http / src / batchHttpLink.ts View on Github external
return new Observable(observer => {
        fetcher(chosenURI, options)
          .then(response => {
            // Make the raw response available in the context.
            operations.forEach(operation => operation.setContext({ response }));
            return response;
          })
          .then(parseAndCheckHttpResponse(operations))
          .then(result => {
            // we have data and can send it to back up the link chain
            observer.next(result);
            observer.complete();
            return result;
          })
          .catch(err => {
            // fetch was cancelled so its already been cleaned up in the unsubscribe
            if (err.name === 'AbortError') return;
            // if it is a network error, BUT there is graphql result info
            // fire the next observer before calling error
            // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networErrors`
            // to pass to UI
            // this should only happen if we *also* have data as part of the response key per
            // the spec
            if (err.result && err.result.errors && err.result.data) {
github apollographql / apollo-link / packages / apollo-link-http / src / httpLink.ts View on Github external
return new Observable(observer => {
      fetcher(chosenURI, options)
        .then(response => {
          operation.setContext({ response });
          return response;
        })
        .then(parseAndCheckHttpResponse(operation))
        .then(result => {
          // we have data and can send it to back up the link chain
          observer.next(result);
          observer.complete();
          return result;
        })
        .catch(err => {
          // fetch was cancelled so it's already been cleaned up in the unsubscribe
          if (err.name === 'AbortError') return;
          // if it is a network error, BUT there is graphql result info
          // fire the next observer before calling error
          // this gives apollo-client (and react-apollo) the `graphqlErrors` and `networErrors`
          // to pass to UI
          // this should only happen if we *also* have data as part of the response key per
          // the spec
          if (err.result && err.result.errors && err.result.data) {
github jaydenseric / apollo-upload-client / src / index.js View on Github external
return new Observable(observer => {
      // Allow aborting fetch, if supported.
      const { controller, signal } = createSignalIfSupported()
      if (controller) options.signal = signal

      linkFetch(uri, options)
        .then(response => {
          // Forward the response on the context.
          operation.setContext({ response })
          return response
        })
        .then(parseAndCheckHttpResponse(operation))
        .then(result => {
          observer.next(result)
          observer.complete()
        })
        .catch(error => {
          if (error.name === 'AbortError')
            // Fetch was aborted.
            return

          if (error.result && error.result.errors && error.result.data)
            // There is a GraphQL result to forward.
            observer.next(error.result)

          observer.error(error)
        })

apollo-link-http-common

Http utilities for Apollo Link shared across all links using http

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis