Skip to content

Instantly share code, notes, and snippets.

@kensmash
kensmash / gist:6ec6cc32deed1cf24dfea4c886eb94c3
Created February 18, 2019 15:51
React Native Canvas test code
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Canvas from "react-native-canvas";
export default class App extends React.Component {
handleCanvas = canvas => {
const ctx = canvas.getContext("2d");
ctx.fillStyle = "purple";
ctx.fillRect(0, 0, 100, 100);
};
const { GraphQLServer } = require("graphql-yoga");
const session = require("express-session");
const { Prisma } = require("prisma-binding");
const resolvers = require("./resolvers");
const db = new Prisma({
typeDefs: "src/generated/prisma.graphql", // the auto-generated GraphQL schema of the Prisma API
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`)
debug: true // log all GraphQL queries & mutations sent to the Prisma API
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`)
const setTokenAfterware = new ApolloLink((operation, forward) => {
const promises = forward(operation).map(async res => {
const context = operation.getContext();
const { response: { headers } } = context;
const token = headers.get["x-token"];
const refreshToken = headers.get["x-refresh-token"];
if (token) {
await AsyncStorage.setItem("token", token);