summaryrefslogtreecommitdiffstats
path: root/graphcool
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-01-30 12:41:01 -0500
committerWes Bos <wesbos@gmail.com>2018-01-30 12:41:01 -0500
commitcd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch)
treea203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /graphcool
parent0a1648bf47490b312169c531aeb51ef4725e8d2e (diff)
Move to Prisma Backend
Diffstat (limited to 'graphcool')
-rw-r--r--graphcool/.graphcoolrc4
-rw-r--r--graphcool/graphcool.yml44
-rw-r--r--graphcool/package-lock.json39
-rw-r--r--graphcool/package.json8
-rw-r--r--graphcool/src/createCharge.js52
-rw-r--r--graphcool/src/createCharge.test.js23
-rw-r--r--graphcool/src/getPrice.js26
-rw-r--r--graphcool/src/hello.graphql7
-rw-r--r--graphcool/src/hello.js11
-rw-r--r--graphcool/src/index.js2
-rw-r--r--graphcool/types.graphql53
11 files changed, 0 insertions, 269 deletions
diff --git a/graphcool/.graphcoolrc b/graphcool/.graphcoolrc
deleted file mode 100644
index a83bc41..0000000
--- a/graphcool/.graphcoolrc
+++ /dev/null
@@ -1,4 +0,0 @@
-targets:
- prod: shared-eu-west-1/cjctbkp4o02fh0105aff50ccn
- default: local
- local: local/cjctdwrq1000e0149tlqfs0c7
diff --git a/graphcool/graphcool.yml b/graphcool/graphcool.yml
deleted file mode 100644
index 6434b57..0000000
--- a/graphcool/graphcool.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-# Welcome to Graphcool!
-#
-# This file is the main config file for your Graphcool Service.
-# It's very minimal at this point and uses default values.
-# We've included a hello world function here.
-# Just run `graphcool deploy` to have the first running Graphcool Service.
-#
-# Check out some examples:
-# https://github.com/graphcool/graphcool/tree/master/examples
-#
-# Here are the reference docs of this definition format:
-# https://docs-next.graph.cool/reference/service-definition/graphcool.yml-foatho8aip
-#
-# Happy Coding!
-
-
-# In the types.graphql you define your data schema
-types: ./types.graphql
-
-
-functions:
-
- createCharge:
- handler:
- code: src/createCharge.js
- type: operationBefore
- operation: Order.create
-
-
-# Model/Relation permissions are used to limit the API access
-# To take the burden of thinking about those while development, we
-# preconfigured the wildcard ("*") permission that allows everything
-# Read more here:
-# https://docs-next.graph.cool/reference/auth/authorization/overview-iegoo0heez
-permissions:
-- operation: "*"
-
-
-# Your root tokens used for functions to get full access to the API
-# Read more here:
-# https://docs-next.graph.cool/reference/auth/authentication/authentication-tokens-eip7ahqu5o
-# rootTokens:
-# - mytoken
-
diff --git a/graphcool/package-lock.json b/graphcool/package-lock.json
deleted file mode 100644
index c952a86..0000000
--- a/graphcool/package-lock.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "name": "graphcool",
- "version": "1.0.0",
- "lockfileVersion": 1,
- "requires": true,
- "dependencies": {
- "bluebird": {
- "version": "3.5.1",
- "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
- "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
- },
- "lodash.isplainobject": {
- "version": "4.0.6",
- "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
- "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
- },
- "qs": {
- "version": "6.5.1",
- "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz",
- "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A=="
- },
- "safe-buffer": {
- "version": "5.1.1",
- "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
- "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
- },
- "stripe": {
- "version": "5.4.0",
- "resolved": "https://registry.npmjs.org/stripe/-/stripe-5.4.0.tgz",
- "integrity": "sha512-VCDFp4oQu1uOcOLHIwRIznH8ikLJcpDsHahWN48V/QuV6y2Bm281cq5wnkjqv+LPdUpqXVp9pjlb+SfN6dnyZg==",
- "requires": {
- "bluebird": "3.5.1",
- "lodash.isplainobject": "4.0.6",
- "qs": "6.5.1",
- "safe-buffer": "5.1.1"
- }
- }
- }
-}
diff --git a/graphcool/package.json b/graphcool/package.json
deleted file mode 100644
index 6fccf4b..0000000
--- a/graphcool/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "graphcool",
- "version": "1.0.0",
- "description": "My Graphcool Service",
- "dependencies": {
- "stripe": "^5.4.0"
- }
-}
diff --git a/graphcool/src/createCharge.js b/graphcool/src/createCharge.js
deleted file mode 100644
index ccf9c11..0000000
--- a/graphcool/src/createCharge.js
+++ /dev/null
@@ -1,52 +0,0 @@
-const stripe = require('stripe')('sk_ycLkGc2cAaBDSCKkHiKVBeT71CMxd');
-
-const endpoint = 'https://api.graph.cool/simple/v1/cj99zm6ye06sb01325ic751ww';
-
-require('isomorphic-fetch');
-
-const getPrice = itemId => {
- const query = `
- query SingleItem {
- Item(id: "${itemId}") {
- price
- }
- }
- `;
-
- return fetch(endpoint, {
- method: 'post',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ query }),
- });
-};
-
-const createStripeCharge = (token, amount) =>
- stripe.charges.create({
- amount,
- currency: 'usd',
- description: `a test charge`,
- source: token,
- });
-
-module.exports = function(event) {
- return new Promise((resolve, reject) => {
- // first find out the price of the item
- getPrice(event.data.itemId)
- .then(res => res.json())
- .then(res => {
- console.log(`Back with the price ${res.data.Item.price}!`);
- return createStripeCharge(event.data.token, res.data.Item.price);
- })
- .then(res => {
- console.log(`Back! charge ${res.id} for the amount ${res.amount}`);
- event.data.charge = res.id;
- event.data.amount = res.amount;
- resolve(event);
- })
- .catch(err => {
- reject(err);
- });
- });
-};
diff --git a/graphcool/src/createCharge.test.js b/graphcool/src/createCharge.test.js
deleted file mode 100644
index 65dde47..0000000
--- a/graphcool/src/createCharge.test.js
+++ /dev/null
@@ -1,23 +0,0 @@
-const takeMoney = require('./createCharge');
-
-const event = {
- "data": {
- "user": "cj6ntm8qic3260140vkuzif9d",
- "token": "tok_visa",
- },
- "context": {
- "headers": {}
- }
-}
-
-
-describe('Take Money', () => {
-
- test('A charge has come back', async () => {
- const res = await takeMoney(event);
- console.log(res);
- expect(res.data.amount).toBeGreaterThanOrEqual(0);
- });
-
-});
-
diff --git a/graphcool/src/getPrice.js b/graphcool/src/getPrice.js
deleted file mode 100644
index 7808a85..0000000
--- a/graphcool/src/getPrice.js
+++ /dev/null
@@ -1,26 +0,0 @@
-require('isomorphic-fetch')
-
-const query = `
-query SingleItem {
- Item(id: "cj64bs7vuuqgu0116ul5cm223") {
- price
- }
-}
-`;
-
-function getItem(id) {
- return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', {
- method: 'post',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({ query }),
- })
-}
-
-
-module.exports = function(event) {
- getItem().then(x => x.json()).then(res => {
- console.log(res.data.Item.price);
- }).catch(console.log)
-}
diff --git a/graphcool/src/hello.graphql b/graphcool/src/hello.graphql
deleted file mode 100644
index d43c729..0000000
--- a/graphcool/src/hello.graphql
+++ /dev/null
@@ -1,7 +0,0 @@
-type HelloPayload {
- message: String!
-}
-
-extend type Query {
- hello(name: String): HelloPayload
-}
diff --git a/graphcool/src/hello.js b/graphcool/src/hello.js
deleted file mode 100644
index 0e3e7ba..0000000
--- a/graphcool/src/hello.js
+++ /dev/null
@@ -1,11 +0,0 @@
-export default async event => {
- // you can use ES7 with async/await and even TypeScript in your functions :)
-
- await new Promise(r => setTimeout(r, 50))
-
- return {
- data: {
- message: `Hello ${event.data.name || 'World'}`
- }
- }
-} \ No newline at end of file
diff --git a/graphcool/src/index.js b/graphcool/src/index.js
deleted file mode 100644
index ee451f6..0000000
--- a/graphcool/src/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-module.exports = () => 'Welcome to Micro'
-exports.what = () => 'What'
diff --git a/graphcool/types.graphql b/graphcool/types.graphql
deleted file mode 100644
index 44fea35..0000000
--- a/graphcool/types.graphql
+++ /dev/null
@@ -1,53 +0,0 @@
-# The following types define the data model of the example service
-# based on which the GraphQL API is generated
-
-type File @model {
- contentType: String!
- createdAt: DateTime!
- id: ID! @isUnique
- item: Item @relation(name: "Photo")
- name: String!
- secret: String! @isUnique
- size: Int!
- updatedAt: DateTime!
- url: String! @isUnique
-}
-
-type Item @model {
- createdAt: DateTime!
- description: String!
- fullPrice: Int
- id: ID! @isUnique
- image: File @relation(name: "Photo")
- order: Order @relation(name: "OrderOnItem")
- price: Int
- title: String!
- updatedAt: DateTime!
- user: User @relation(name: "CartItems")
-}
-
-type Order @model {
- amount: Int
- charge: String
- createdAt: DateTime!
- id: ID! @isUnique
- item: Item @relation(name: "OrderOnItem")
- token: String
- updatedAt: DateTime!
- user: User @relation(name: "OrderOnUser")
-}
-
-type User @model {
- createdAt: DateTime!
- email: String @isUnique
- id: ID! @isUnique
- isVerified: Boolean! @defaultValue(value: false)
- orders: [Order!]! @relation(name: "OrderOnUser")
- password: String
- secret: String @isUnique
- updatedAt: DateTime!
- auth0UserId: String @isUnique
- name: String!
- cart: [Item!]! @relation(name: "CartItems")
- level: Int
-}