ApolloLink.from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.log( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`, ), ); if (networkError) console.log(`[Network error]: ${networkError}`); }), new HttpLink({ uri: 'https://us1.prisma.sh/public-luckox-377/reservation-graphql-backend/dev', credentials: 'same-origin' }) ])
function _default(options) { var links = [(0, _onError["default"])(options)]; if (options.useSubscriptions) { var httpLink = (0, _createHttpLink["default"])(options); var wsLink = (0, _createWsLink["default"])(options); var link = (0, _apolloLink.split)(function (_ref) { var query = _ref.query; var _getMainDefinition = (0, _apolloUtilities.getMainDefinition)(query), kind = _getMainDefinition.kind, operation = _getMainDefinition.operation; return kind === 'OperationDefinition' && operation === 'subscription'; }, wsLink, httpLink); links.push(link); } else { links.push((0, _createHttpLink["default"])(options)); } return _apolloLink.ApolloLink.from(links); }
const createApolloClient = (options) => { const cache = new InMemoryCache(); if (options.initialState) { cache.restore(options.initialState); } const link = ApolloLink.from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`) ); if (networkError) console.log(`[Network error]: ${networkError}`); }), createHttpLink({ uri: API_ENDPOINT, fetch }), ]); return new ApolloClient({ link, cache, ...options }); }
export default function(options) { const links = [onError(options)] if (options.useSubscriptions) { const httpLink = createHttpLink(options) const wsLink = createWsLink(options) const link = split( ({query}) => { const {kind, operation} = getMainDefinition(query) return kind === 'OperationDefinition' && operation === 'subscription' }, wsLink, httpLink ) links.push(link) } else { links.push(createHttpLink(options)) } return ApolloLink.from(links) }
ApolloLink.from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.log( `[GraphQL error]: Message:, ${message}, Location:, ${locations}, Path:, ${path}`, ), ); if (networkError) console.log(`[Network error]: ${networkError}`); }), new HttpLink({ uri: `http://localhost:${GraphqlPort}/graphql`, }) ])
ApolloLink.from([ apolloLocalStateSetup, onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`), ) if (networkError) console.log(`[Network error]: ${networkError}`) }), new HttpLink({ uri: 'http://localhost:4000', credentials: 'same-origin', }), ])
ApolloLink.from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) { graphQLErrors.map(({ message, locations, path }) => console.log( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` ) ) } if (networkError) console.log(`[Network error]: ${networkError}`) }), new HttpLink({ uri: `https://graphql.contentful.com/content/v1/spaces/${SPACE_ID}`, credentials: 'same-origin', headers: { Authorization: `Bearer ${ACCESS_TOKEN}` } }) ])