Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutation does not work due to authentication in 3-mutations-creating-links #677

Closed
jseminck opened this issue Jun 17, 2018 · 3 comments
Closed

Comments

@jseminck
Copy link

Hello!

Not sure if this is a bug... but first I did the server/backend code with the Node tutorial. In this project, we add authentication to the post mutation.

The steps in the FE tutorial setup the post mutation in a form. But the authentication is not yet implemented. As a result, I get the error Uncaught (in promise) Error: GraphQL error: Not authenticated instead of creating a new link.

https://www.howtographql.com/react-apollo/3-mutations-creating-links/

@craigblunden
Copy link

I had the same issue, I just moved forward to up until the Auth section to make sure it all worked accordingly but I agree its a bit jarring without that context.

@jh0l
Copy link

jh0l commented Jul 21, 2018

Yeah, one caveat of reusing the node tutorial code I guess. My workaround was commenting out the getUserId line in the post resolver and setting the postedBy field of the database api request to null,
like this

async function post(parent, args, ctx, info) {
  //const userId = getUserId(ctx);
  return await ctx.db.mutation.createLink(
    {
      data: {
        url: args.url,
        description: args.description,
        postedBy: null//{ connect: { id: userId } }
      }
    },
    info
  );
}

Which should work because the User field for the Link entity is not !. this is basically the reverse of what is done in the authentication section further in the react-apollo tutorial too so pretty easy to undo when necessary.

@itscarlosrufo
Copy link
Contributor

Thanks @jseminck for opening this issue 😄. it should be fixed. Closing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants