|
6 | 6 |
|
7 | 7 | const { createApolloFetch } = require('apollo-fetch'); |
8 | 8 |
|
9 | | -const createPrismaNodes = async variables => { |
10 | | - const uri = |
11 | | - 'https://howtographql-prod_howtographql-internal.prisma.sh/howtographql/dev'; |
12 | | - const apolloFetch = createApolloFetch({ uri }); |
13 | | - const query = ` |
14 | | - mutation upsertTutorial( |
15 | | - $gatsbyID: String! |
16 | | - $name: String! |
17 | | - $numberofChapters: Int! |
18 | | - ) { |
19 | | - upsertTutorial( |
20 | | - where: { gatsbyID: $gatsbyID } |
21 | | - create: { |
22 | | - gatsbyID: $gatsbyID |
23 | | - name: $name |
24 | | - numberofChapters: $numberofChapters |
25 | | - } |
26 | | - update: { |
27 | | - gatsbyID: $gatsbyID |
28 | | - name: $name |
29 | | - numberofChapters: $numberofChapters |
30 | | - } |
31 | | - ) { |
32 | | - id |
33 | | - } |
34 | | - } |
35 | | - `; |
36 | | - return apolloFetch({ query, variables }) |
37 | | - .then(response => { |
38 | | - console.log(response); |
39 | | - }) |
40 | | - .catch(error => { |
41 | | - console.log(error); |
42 | | - }); |
43 | | -}; |
44 | | - |
45 | 9 | exports.createPages = async ({ graphql, actions }) => { |
46 | 10 | const { createPage } = actions; |
47 | 11 | const TutorialLayout = require.resolve( |
@@ -112,6 +76,42 @@ exports.createPages = async ({ graphql, actions }) => { |
112 | 76 | }); |
113 | 77 | }; |
114 | 78 |
|
| 79 | +const createPrismaNodes = async variables => { |
| 80 | + const uri = |
| 81 | + 'https://howtographql-prod_howtographql-internal.prisma.sh/howtographql/dev'; |
| 82 | + const apolloFetch = createApolloFetch({ uri }); |
| 83 | + const query = ` |
| 84 | + mutation upsertTutorial( |
| 85 | + $gatsbyID: String! |
| 86 | + $name: String! |
| 87 | + $numberofChapters: Int! |
| 88 | + ) { |
| 89 | + upsertTutorial( |
| 90 | + where: { gatsbyID: $gatsbyID } |
| 91 | + create: { |
| 92 | + gatsbyID: $gatsbyID |
| 93 | + name: $name |
| 94 | + numberofChapters: $numberofChapters |
| 95 | + } |
| 96 | + update: { |
| 97 | + gatsbyID: $gatsbyID |
| 98 | + name: $name |
| 99 | + numberofChapters: $numberofChapters |
| 100 | + } |
| 101 | + ) { |
| 102 | + id |
| 103 | + } |
| 104 | + } |
| 105 | + `; |
| 106 | + return apolloFetch({ query, variables }) |
| 107 | + .then(response => { |
| 108 | + console.log(response); |
| 109 | + }) |
| 110 | + .catch(error => { |
| 111 | + console.log(error); |
| 112 | + }); |
| 113 | +}; |
| 114 | + |
115 | 115 | // overviewpages = overviewpages |
116 | 116 | // .filter(p => p !== overviewPageSlug) |
117 | 117 | // .concat([overviewPageSlug]); |
|
0 commit comments