I have a problem with Apollo Client-React.
I want to send a login request when the user doing click in Log In button.
My code is:
// @vendors
import React from 'react';
import {
withApollo
} from 'react-apollo';
import ApolloClient from 'apollo-client';
import gql from 'graphql-tag';
import { Link } from 'react-router';
class Login extends React.Component {
constructor() {
super();
this.state = {
email: 'user1@email.com'
}
this.sendRequest = this.sendRequest.bind(this);
}
sendRequest() {
const {
email
} = this.state;
const FETCH_USER = gql`
query fetchUser($email: String!) {
user(email: $email) {
id
}
}
`;
return this.props.client.query({
query: FETCH_USER,
variables: {email: email}
})
}
render() {
return (
<form>
<div className="form-group">
<label htmlFor="email">Email:</label>
<input type="email" className="form-control" id="email" />
</div>
<div className="form-group">
<label htmlFor="password">Password:</label>
<input type="password" className="form-control" id="password" />
</div>
<button onClick={this.sendRequest} className="btn btn-default">Log In</button>
</form>
);
}
}
Login.propTypes = {
client: React.PropTypes.instanceOf(ApolloClient).isRequired,
}
export default withApollo(Login);
The console shows:
Uncaught (in promise) Error: Network error: Could not find query inside query map.
Can anybody help me?
UPDATE:
I used this versions:
- "apollo-client": "^0.6.0"
- "react-apollo": "^0.9.0"