GraphQL error: Cannot query field 'authenticateUser' on type 'Mutation'


#1

Hi,
I am learning graphcool and setting up a facebook login with react native and apollo.
I have this query:

const AUTHENTICATE_FACEBOOK_USER = gql`
mutation AuthenticateUserMutation($facebookToken: String!) {
authenticateUser(facebookToken: $facebookToken) {
    token
  }
}

`

but I get this error on the callback:
GraphQL error: Cannot query field ‘authenticateUser’ on type ‘Mutation’. Did you mean ‘updateUser’ or
’createUser’? (line 2, column 3):
authenticateUser(facebookToken: $facebookToken) {
^

Any help on this? Thanks.


#2

Your project does not contain this mutation. Did you add a respective resolver with that name?


#3

Nilan, thanks for your reply.

I am very beginner with graphql, could you please explain me better what to do in my project? I tried to follow a tutorial on the website but it’s not for react-native and it is different. However I downloaded the facebook template from github. Thanks in advance.


#4

In the Graphcool Framework, you need to deploy resolver functions to modify your schema. Did you add such a function in graphcool.yml?


#5

I changed the hello function handlers from the template to this:

functions:
hello:
handler:
code: src/facebook/facebookAuthentication.ts
type: resolver
schema: src/facebookAuthentication.graphql


#6

Did you deploy afterwards?


#7

if you have any good tutorial to point me would be good. I understand I am too beginner for it :slight_smile:


#8

Yes, I deployed and got the endpoints


#9

Ok, I tried to deploy again and got another error:

Custom clusters (local/private):
local ▸ path must be a string or Buffer


#10

The quickstart is a good option: https://www.graph.cool/docs/quickstart/ :slight_smile:


#11

Ok @nilan I followed your instructions read the quickstart guide. I am getting better :slight_smile:
So now I deployed correctly and then call the mutation, but I get this error that does not help at all:
From the logs:
{ "error": "Function returned invalid status code: 0. Raw body: empty.last" }

What I do, after installing and deploying the facebook template is :
this.props.authenticateUserMutation({variables: { facebookToken }}).then((r) => { console.log("RESPONSE FROM GRAPHQL: ", r); this.props.setToken(token.accessToken); })

It is hard to understand what I am doing wrong, I can see from the logs that the function gets the facebookId and the token, but I don’t understand where it is failing.
Do you have any suggestion? Thank you!