启用 POST 方法到 Laravel Folklore\GraphQL 或在 react-apollo 中启用 GET 方法

Enable POST method to Laravel Folklore\GraphQL or enable GET method in react-apollo

我尝试将 React 与 Laravel 的 Folklore\GraphQL 连接起来。

在 ReactJS 中我有这段代码 index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import registerServiceWorker from './registerServiceWorker';

import { ApolloClient, ApolloProvider, createNetworkInterface } from 'react-apollo';
import Devices from './components/Devices.js'

const networkInterface = createNetworkInterface({
    uri: 'http://127.0.0.1:8000/graphiql',
    opts: {
        credentials: 'same-origin',
        mode: 'no-cors',
    },
});
const client = new ApolloClient({ networkInterface });

ReactDOM.render(
  <ApolloProvider client={client}>
    <Devices />
  </ApolloProvider>,
  document.getElementById('root')
)

并且在Devices.js

import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import gql from 'graphql-tag';

class Devices extends Component {
    render() {
        console.log(this.props);
        return(
            <div>Hello</div>
        );
    }
}

const query = gql`
{
    devices {
        id_device,
        name,
        type,
    }
}
`;
export default graphql(query)(Devices);

但是显示错误:

POST http://127.0.0.1:8000/graphiql 405 (Method Not Allowed)

如果我在 opts 中添加到 method:'GET' 显示以下错误:

Unhandled (in react-apollo) Error: Network error: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.

如何将方法 POST 添加到 Folklore\GraphQL? 如何将 GET 方法设置为 ApolloClient?

错误是我的,因为y放了GraphQL接口的URL。 URL 正确的是 http://127.0.0.1:8000/graphql