This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GET_DATA = ``; // some query | |
const WithQuery = Component => props => ( | |
<DataQuery query={GET_DATA}> | |
{({ loading, error, data }) => { | |
if (loading) { | |
// ... | |
} | |
if (error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Auth0Lock from 'auth0-lock'; | |
import gql from 'graphql-tag'; | |
import * as jwt from 'jsonwebtoken'; | |
import { Config } from '../../../config'; | |
const AUTH0_DOMAIN = Config.AUTH0_DOMAIN; | |
class AuthService { | |
public static isLoggedIn(): boolean { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ApolloClient, { createNetworkInterface } from 'apollo-client'; | |
import { AuthService } from './services'; // whatever you're using for user state | |
const isLoggedIn = AuthService.isLoggedIn(); | |
const token = AuthService.getToken(); | |
const authHeader = { | |
applyMiddleware(req, next) { | |
if (!req.options.headers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": {}, | |
"errors": [ | |
{ | |
"message":"A foo error has occurred", | |
"name":"FooError", | |
"time_thrown":"2016-11-11T00:40:50.954Z", | |
"data":{ | |
"something": "important" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphQLServer.use( | |
'/', | |
bodyParser.json(), | |
graphqlExpress((req) => ({ context: req.user, schema: Schema })), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const userResolver = { | |
Query: { | |
async user( | |
_, | |
{ userId }, // query variable | |
currUser // context | |
) { | |
const psqlDriver = getPsqlDriver(); | |
authorizeRead(userId, currUser); |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
engine = pg | |
[engine "pg"] | |
client = psql | |
[target "dev"] | |
uri = db:pg://postgres@localhost/postgres | |
[target "staging"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- deploy/users-email-col.sql | |
-- Deploy myproject:users-email-col to pg | |
BEGIN; | |
ALTER TABLE users | |
ADD COLUMN email VARCHAR(100); | |
COMMIT; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- deploy/users.sql | |
-- Deploy myproject:users to pg | |
BEGIN; | |
CREATE TABLE users ( | |
id INTEGER PRIMARY KEY, | |
first_name VARCHAR(45), | |
last_name VARCHAR(45), | |
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), |
NewerOlder