Skip to content

Instantly share code, notes, and snippets.

View nicolasdao's full-sized avatar

Nicolas Dao nicolasdao

View GitHub Profile
const schema = `
type Paged<T> {
data: [T]
cursor: ID
}
type Node {
id: ID!
creationDate: String
}
const { transpileSchema } = require('graphql-s2s').graphqls2s
const { makeExecutableSchema } = require('graphql-tools')
const schema = `
type Paged<T> {
data: [T]
cursor: ID
}
...
`
const schema = `
...
@alias(T => T.match(/s$/) ? T+'es' : T.match(/y$/) ? T.replace(/y$/, 'ies') : T+'s')
type Paged<T> {
data: [T]
page: Page
}`
- src/
|__ schema.js
- index.js
- package.json
// index.js
const { makeExecutableSchema } = require('graphql-tools')
const glue = require('schemaglue')
const { schema, resolver } = glue('src/graphql')
const executableSchema = makeExecutableSchema({
typeDefs: schema,
resolvers: resolver
@nicolasdao
nicolasdao / login.html
Last active March 17, 2019 23:16
login.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="https://neap.co/favicon.ico">
<title>Login</title>
<link rel="canonical" href="/login.html">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json">
@nicolasdao
nicolasdao / serverless_regions.md
Last active July 2, 2023 08:06
Serverless Regions

AMAZON API GATEWAY REGIONS

US East (Ohio) us-east-2 apigateway.us-east-2.amazonaws.com HTTPS ZOJJZC49E0EPZ

US East (N. Virginia) us-east-1 apigateway.us-east-1.amazonaws.com HTTPS Z1UJRXOUMOOFQ8

US West (N. California) us-west-1 apigateway.us-west-1.amazonaws.com HTTPS Z2MUQ32089INYE

US West (Oregon) us-west-2 apigateway.us-west-2.amazonaws.com HTTPS Z2OJLYMUO9EFXC

Without SchemaGlue - Stuck With a Monolithic Schema

- src/
   |__ schema.js

- index.js
- package.json

With SchemaGlue - Structure Your Schema At Will

# schema.graphql file
# Magic Generic Type.
type Paged<T> {
data: [T]
cursor: ID
}
type Node {
id: ID!
// INIT THE LOGGER
// All environment and all projects logs to the same papertrail account (defined by its specific ACCOUNT_PORT).
// The papertrail paradigm is to log everything to the same container, and then use filters (aka searches) to
// containerize your logs on the fly.
const winston = require('winston')
require('winston-papertrail').Papertrail
const ACCOUNT_PORT = 1234
const PROJECT = 'your-project-name'