简体   繁体   English

GraphQL JSON 输入意外结束

[英]GraphQL Unexpected end of JSON input

I'm developing an app on Shopify, i included GraphQL and i start to get relevant error.我正在 Shopify 上开发一个应用程序,我包含了 GraphQL 并且开始出现相关错误。 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 _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;

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另外,我将graphql的api版本更改为October20

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM