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

-1

I'm trying to connect React with Folklore \ GraphQL from Laravel.

In ReactJS I have the following code in 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')
)

And in 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);

But it shows the following error:

  

POST link 405 (Method Not Allowed)

And if I add the method:'GET' in opts shows the following error:

  

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

How can you add the POST method to Folklore \ GraphQL? How can you add the GET method to ApolloClient?

    
asked by albertcito 08.10.2017 в 22:33
source

1 answer

0

The error was mine, because I put the URL of the GraphQL interface. The correct URL is link graphql

    
answered by 08.10.2017 / 23:22
source