Skip to content

Commit c63c991

Browse files
committed
change graphcool endpoint to Prisma endpoint
1 parent 447d662 commit c63c991

File tree

3 files changed

+602
-575
lines changed

3 files changed

+602
-575
lines changed

packages/gatsby-theme/gatsby-node.js

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,32 @@ const {
77
const { createApolloFetch } = require('apollo-fetch');
88

99
const createPrismaNodes = async variables => {
10-
const uri = 'https://api.graph.cool/simple/v1/HowtoGraphQL2';
10+
const uri =
11+
'https://howtographql-prod_howtographql-internal.prisma.sh/howtographql/dev';
1112
const apolloFetch = createApolloFetch({ uri });
1213
const query = `
13-
mutation createTutorial($gatsbyID: String!, $name: String!, $numberofChapters: Int!) {
14-
createTutorial(gatsbyID: $gatsbyID, name: $name, numberofChapters: $numberofChapters, numberOfStudents: 9, upvotes:10){
15-
id
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+
}
1634
}
17-
}`;
35+
`;
1836
return apolloFetch({ query, variables })
1937
.then(response => {
2038
console.log(response);
@@ -60,16 +78,17 @@ exports.createPages = async ({ graphql, actions }) => {
6078
if (node.frontmatter.tutorialTitle) {
6179
//counts the number of chapters in each tutorial by counting how many files
6280
//there are that contain the overviewpage slug. Subtract one for the overview page.
63-
const numberofChapters = data.allMdx.edges.filter(chapterNode => {
64-
return chapterNode.node.fileAbsolutePath.includes(
65-
`${overviewPageSlug}/`,
66-
);
67-
});
81+
const numberofChapters =
82+
data.allMdx.edges.filter(chapterNode => {
83+
return chapterNode.node.fileAbsolutePath.includes(
84+
`${overviewPageSlug}/`,
85+
);
86+
}).length - 1;
6887

6988
const variables = {
7089
gatsbyID: node.frontmatter.id,
7190
name: node.frontmatter.tutorialTitle,
72-
numberofChapters: numberofChapters.length - 1,
91+
numberofChapters: numberofChapters,
7392
};
7493
createPrismaNodes(variables);
7594

0 commit comments

Comments
 (0)