Skip to content

Instantly share code, notes, and snippets.

View clarencenpy's full-sized avatar

Clarence Ngoh clarencenpy

View GitHub Profile
{
"error": {
"graphQLErrors": [
{
"message": "forbidden",
"locations": [],
"path": [
"protectedAction"
],
"extensions": {
import { AuthenticationError } from 'apollo-server'
const resolvers = {
Mutation: {
protectedAction(root, args , { user }) {
if (!user) {
throw new AuthenticationError('You must be logged in');
}
}
}
};
{
"errors": [{
"message": "Something went wrong",
"locations": [
{
"line": 3,
"column": 5
}
],
}]
import React from 'react';
import { render } from 'react-dom';
import ApolloClient from 'apollo-boost';
import { ApolloProvider } from 'react-apollo';
// Pass your GraphQL endpoint to uri
const client = new ApolloClient({
uri: 'https://nx9zvp49q7.lp.gql.zone/graphql'
});