0
votes

I'm developing an app on Shopify, i included GraphQL and i start to get relevant error. previously i got network errors additionally, after additional a few lines, i got rid out of "network error", but still i am in trouble. please help me!

_app.js

import React from 'react';
import App from 'next/app';
import Head from 'next/head';
import { AppProvider } from "@shopify/polaris";
import translations from "@shopify/polaris/locales/en.json";
import "@shopify/polaris/dist/styles.css";
import { ApolloClient, HttpLink, ApolloLink, InMemoryCache, concat } from '@apollo/client';
//import { ApolloClient } from 'apollo-client';
import { createHttpLink } from 'apollo-link-http';
//import { InMemoryCache } from 'apollo-cache-inmemory';
import {ApolloProvider} from 'react-apollo'
const client = new ApolloClient({
  link: new createHttpLink({
    credentials: 'include',
    headers: {
      'Content-Type': 'application/graphql',
    },
  }),
  cache: new InMemoryCache(),
})

/*
import ApolloClient from 'apollo-boost';
import {ApolloProvider} from 'react-apollo'

const client = new ApolloClient({
  fetchOptions: {
    uri:'/graphql',
    credentials: 'include'
  },
});
*/

class MyApp extends App {
  render()
  {
    const {Component, pageProps} = this.props;

    return(
      <React.Fragment>
      <Head>
      <title>Elena App</title>
      <meta charSet="utf-8"/>
      </Head>
      <AppProvider i18n={translations}>
       <ApolloProvider client={client}>
       <Component {...pageProps} />
       </ApolloProvider>
      </AppProvider>

      </React.Fragment>
    );
  }
}

export default MyApp;

1
i am fairly new if server.js is needed i can post it thereMustafa Mustafa Neverrun
Yes, please post server.jsManny
thanks for your care, problem seems fixed const client = new ApolloClient({ uri:'/graphql', fetchOptions:{ credentials:'include' }, cache: new InMemoryCache(),//I added this line and problem seems to be fixed for now. });Mustafa Mustafa Neverrun

1 Answers

0
votes
const client = new ApolloClient({
  uri:'/graphql',
  fetchOptions:{
    credentials:'include'
  },
  cache: new InMemoryCache(),//I add this line and problem fixed
});

Also , i changed api version of graphql to October20