Skip to content

Instantly share code, notes, and snippets.

View timsuchanek's full-sized avatar
🐋

Tim Suchanek timsuchanek

🐋
View GitHub Profile
#!/bin/bash
#
# Prisma Node.JS packages publish script
#
# Build Order
# prisma-client-lib
# prisma-generate-schema
# prisma-db-introspection
import { addFragmentToInfo } from 'graphql-binding'
async signup(parent, args, ctx, info) {
args.email = args.email.toLowerCase();
const password = await bcrypt.hash(args.password, 10);
const user = await ctx.db.mutation.createUser(
{
data: {
...args,
password,
permissions: { set: ['USER'] },
@timsuchanek
timsuchanek / TestClient.ts
Created April 13, 2018 16:39
Yoga Testing
import * as http from 'http'
import * as https from 'https'
import { GraphQLClient } from 'graphql-request'
const debug = require('debug')('TestClient')
import { GraphQLServer } from 'graphql-yoga'
import { server } from '../server'
export default class TestClient {
app: GraphQLServer
server: http.Server
import { GraphQLServer } from 'graphql-yoga'
import { createRemoteSchema, Delegate, collectTypeDefs, RemoteLink, RemoteSubscriptionsLink, giveMeASchemaFactoryNow, fetchSchema } from 'graphql-remote'
import * as jwt from 'jsonwebtoken'
import { GraphQLSchema } from 'graphql'
import { makeRemoteSchema } from '../src/createRemoteSchema/createRemoteSchema'
async function run() {
const makeLink = () => new HybridLink({
http: {
@timsuchanek
timsuchanek / subscription.html
Created November 15, 2017 14:11
Minimal GraphQL Subscription working with subscriptions-transport-ws 0.9.1
<html>
<head>
<title>Websockets Test</title>
</head>
<body>
<script>
const socket = new WebSocket(
'wss://subscriptions.graph.cool/v1/cirs1ufsg02b101619ru0bx5r','graphql-ws'
)
socket.addEventListener('open', event => {
type User @model {
id: ID! @isUnique
createdAt: DateTime!
updatedAt: DateTime!
firstName: String!
lastName: String!
email: String! @isUnique
isSuperHost: Boolean! @defaultValue(value: "false")
ownedPlaces: [Place!]! @relation (name: "PlaceOwner")
location: Location! @relation (name: "UserLocation")
@timsuchanek
timsuchanek / cla.md
Last active September 8, 2020 09:23
Prisma Data, Inc. Contributor Agreement

Contributing to Prisma

Thank you for contributing code to Prisma! Like many projects, we need a contributor license agreement from you before we can merge in your changes.You only need to fill out this agreement once. In brief, by submitting your code to the Prisma project, you are granting us a right to use that code under the terms of this Agreement, including providing it to others. You are also certifying that you wrote it, and that you are allowed to license it to us. You are not giving up your copyright in your work. Contributor License Agreements are important because they define the chain of ownership of a piece of software. Some companies won't allow the use of free software without clear agreements around code ownership. That's why many open source projects collect similar agreements from contributors. Please read this document carefully before signing and keep a copy for your records. (You'll get an email confirmation when you electro

@timsuchanek
timsuchanek / CHANGELOG.md
Last active September 11, 2017 19:55
graphcool cli 1.3.13

Changes

  • hello world as blank project
  • removed debug .json files
  • proper formatted graphcool.yml of blank project
  • proper printing of init command
  • proper printing of add command
  • better usage command (graphcool help)
  • rename schemaExention to resolver
  • function logs
  • get-root-token
@timsuchanek
timsuchanek / observe.js
Last active March 2, 2017 22:23
Observe Subscriptions
import { Observable } from 'rxjs/Observable'
import { SubscriptionClient } from 'subscriptions-transport-ws'
const ws = new SubscriptionClient("endpointurl")
const observable = Observable.create(observer => {
const id = this.ws.subscribe(graphQLParams, (err, res) => {
if (err) {
observer.next(res)
observer.unsubscribe()
}
@timsuchanek
timsuchanek / ExcludeProps.jsx
Created October 25, 2016 13:54
Sometimes you have unwanted props in a child, especially when {...props} is used. This Wrapper Component filters them.
function ExcludeProps(Component: any, filter: string[] = []) {
return (props) => {
const keys = Object.keys(props).filter(key => !filter.includes(key))
const picked = lodash.pick(props, keys)
return <Component {...picked} />
}
}