Skip to content

Instantly share code, notes, and snippets.

View chris-feist's full-sized avatar

Chris Feist chris-feist

View GitHub Profile
@chris-feist
chris-feist / babel.config.js
Created March 4, 2020 21:44
Babel Config for production GraphQL server example
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
@chris-feist
chris-feist / index.js
Created March 3, 2020 20:08
GraphQL Playground Handler for production GraphQL server example
import { ApolloServer } from 'apollo-server-lambda';
import lambdaPlayground from 'graphql-playground-middleware-lambda';
import schema from './schema';
const ENABLE_INTROSPECTION = process.env.STAGE !== 'prod';
const server = new ApolloServer({
schema,
playground: ENABLE_INTROSPECTION,
@chris-feist
chris-feist / index.js
Created March 3, 2020 19:28
GraphQL Handler for production GraphQL server example
import { ApolloServer } from 'apollo-server-lambda';
import schema from './schema';
const ENABLE_INTROSPECTION = process.env.STAGE !== 'prod';
const server = new ApolloServer({
schema,
playground: ENABLE_INTROSPECTION,
introspection: ENABLE_INTROSPECTION,
@chris-feist
chris-feist / index.js
Created March 3, 2020 19:20
Temporary GraphQL schema for production GraphQL server example
import { makeExecutableSchema } from 'graphql-tools';
import gql from 'graphql-tag';
const pingSchema = gql`
type Query {
"Returns 'pong'"
ping: String
}
`;
@chris-feist
chris-feist / useWindowDropZone.js
Last active July 1, 2019 15:03
React Hooks: useWindowDropZone.js isDragging
import { useEffect, useCallback, useState, useRef } from 'react';
export default (args) => {
const { onDrop } = args;
const dragCount = useRef(0);
const [isDragging, setDragging] = useState(false);
const onDragEnterCallback = useCallback((event) => {
event.preventDefault();
@chris-feist
chris-feist / useWindowDropZone.js
Last active July 1, 2019 15:02
React Hooks: useWindowDropZone.js drop dragover
import { useEffect, useCallback } from 'react';
export default (args) => {
const { onDrop } = args;
const onDropCallback = useCallback((event) => {
event.preventDefault();
onDrop(event);
}, [onDrop]);
@chris-feist
chris-feist / useWindowDropZone.js
Last active June 28, 2019 22:11
React Hooks: useWindowDropZone.js onDrop
import { useEffect } from 'react';
export default (args) => {
const {
onDrop,
} = args;
useEffect(() => {
window.addEventListener('drop', onDrop);
return () => {
@chris-feist
chris-feist / useWindowDropZone.js
Last active June 28, 2019 22:02
React Hooks: useWindowDropZone.js shell
export default (args) => {
};
resources:
tables:
Users:
name: ${opt:stage}-Users # Table name
partitionKey: userId
sortKey: state
indexes:
# Global Secondary Index
- name: EmailIndex
partitionKey: email
resources:
tables:
Music:
partitionKey: Artist
sortKey: SongTitle
indexes:
- name: GenreByTitleIndex
partitionKey: Genre
sortKey: AlbumTitle
streamType: newItem