Skip to content

Commit 0181f0a

Browse files
committed
move page queries back to pages
1 parent 197bbc9 commit 0181f0a

File tree

12 files changed

+110
-133
lines changed

12 files changed

+110
-133
lines changed

packages/gatsby-theme/src/components/Percentage.tsx

-16
This file was deleted.

packages/gatsby-theme/src/components/community/BookmarkMutation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { Mutation } from 'react-apollo';
33
import { loginUser } from '../../utils/auth';
44
import { BookmarkButton } from '../shared/buttons';
5-
import { BookmarkTutorial } from '../../utils/queries/tutorial';
5+
import { BookmarkTutorial } from '../../utils/queries';
66
import { handleMutationResponse, ApiErrors } from '../../utils/errorHandling';
77

88
const BookmarkMutation = ({ tutorial }) => (

packages/gatsby-theme/src/components/community/TutorialListing.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@ import { Link } from 'gatsby';
55
import { Query } from 'react-apollo';
66
import UpvoteMutation from './UpvoteMutation';
77
import BookmarkMutation from './BookmarkMutation';
8-
<<<<<<< HEAD
9-
import Percentage from './Percentage';
10-
import { getTutorialbyGatsbyID } from '../utils/queries/tutorial';
11-
=======
128
import Percentage from '../shared/Percentage';
13-
import { GatsbyTutorialQuery } from '../../utils/queries/tutorial';
14-
>>>>>>> update imports on files
9+
import { getTutorialbyGatsbyID } from '../../utils/queries';
1510

1611
type TutorialListingProps = {
1712
tutorial: Tutorial;

packages/gatsby-theme/src/components/community/UpvoteMutation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { loginUser } from '../../utils/auth';
44
import { handleMutationResponse, ApiErrors } from '../../utils/errorHandling';
55
import { VoteButton } from '../shared/buttons';
66
import { Heading, Flex } from '../shared/base';
7-
import { UpvoteTutorial } from '../../utils/queries/tutorial';
7+
import { UpvoteTutorial } from '../../utils/queries';
88

99
const UpvoteMutation = ({ tutorial }) => (
1010
<Mutation mutation={UpvoteTutorial} variables={{ id: tutorial.id }}>

packages/gatsby-theme/src/components/tutorial/ChapterMutation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { upsertCurrentChapter } from '../../utils/queries/tutorial';
2+
import { upsertCurrentChapter } from '../../utils/queries';
33
import { Mutation } from 'react-apollo';
44
import { loginUser } from '../../utils/auth';
55
import { handleMutationResponse, ApiErrors } from '../../utils/errorHandling';

packages/gatsby-theme/src/pages/community.tsx

+26-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import Layout from '../components/shared/layout';
33
import { Content } from '../components/shared/styledHelpers';
44
import TutorialListing from '../components/community/TutorialListing';
55
import { Heading } from '../components/shared/base';
6-
import { CommunityTutorialQuery } from '../utils/queries/markdown';
6+
import { graphql } from 'gatsby';
77

8-
const Community = ({ data }) => {
8+
const community = ({ data }) => {
99
const tutorials = data.tutorials.edges;
1010
return (
1111
<Layout>
@@ -23,4 +23,27 @@ const Community = ({ data }) => {
2323
);
2424
};
2525

26-
export default Community;
26+
export const query = graphql`
27+
query CommunityTutorialQuery {
28+
tutorials: allMdx(
29+
filter: {
30+
frontmatter: { tutorialTitle: { ne: null } }
31+
fileAbsolutePath: { regex: "/community/" }
32+
}
33+
) {
34+
edges {
35+
node {
36+
id
37+
fileAbsolutePath
38+
frontmatter {
39+
id
40+
tutorialTitle
41+
description
42+
}
43+
}
44+
}
45+
}
46+
}
47+
`;
48+
49+
export default community;

packages/gatsby-theme/src/pages/courses.tsx

+40-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Layout from '../components/shared/layout';
33
import CourseSection from '../components/courses/CourseSection';
44
import { Content } from '../components/shared/styledHelpers';
55
import { Heading, Text } from '../components/shared/base';
6-
import { FullStackCourseQuery } from '../utils/queries/markdown';
6+
import { graphql } from 'gatsby';
77

88
const courses = ({ data }) => {
99
const courseSectionData = [
@@ -43,4 +43,43 @@ const courses = ({ data }) => {
4343
);
4444
};
4545

46+
export const query = graphql`
47+
query FullStackCourseQuery {
48+
frontend: allMdx(
49+
filter: {
50+
frontmatter: { tutorialTitle: { ne: null } }
51+
fileAbsolutePath: { regex: "/courses/frontend/" }
52+
}
53+
) {
54+
edges {
55+
node {
56+
id
57+
fileAbsolutePath
58+
frontmatter {
59+
tutorialTitle
60+
description
61+
}
62+
}
63+
}
64+
}
65+
backend: allMdx(
66+
filter: {
67+
frontmatter: { tutorialTitle: { ne: null } }
68+
fileAbsolutePath: { regex: "/courses/backend/" }
69+
}
70+
) {
71+
edges {
72+
node {
73+
id
74+
fileAbsolutePath
75+
frontmatter {
76+
tutorialTitle
77+
description
78+
}
79+
}
80+
}
81+
}
82+
}
83+
`;
84+
4685
export default courses;

packages/gatsby-theme/src/pages/profile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Heading, Text, Image, Flex } from '../components/shared/base';
44
import { logoutUser } from '../utils/auth';
55
import { navigate } from 'gatsby';
66
import { Query } from 'react-apollo';
7-
import { PROFILE_QUERY } from '../utils/queries/profile';
7+
import { PROFILE_QUERY } from '../utils/queries';
88
import { optionalChaining } from '../utils/helpers';
99
import { CenteredLoader } from '../components/shared/Loader';
1010

packages/gatsby-theme/src/utils/queries/tutorial.tsx packages/gatsby-theme/src/utils/queries.tsx

+32
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,35 @@ export const UpvoteTutorial = gql`
6060
}
6161
}
6262
`;
63+
64+
export const PROFILE_QUERY = gql`
65+
query profileQuery {
66+
viewer {
67+
user {
68+
id
69+
name
70+
githubHandle
71+
avatarUrl
72+
bio
73+
upvoted: userTutorials(where: { upvoted: true }) {
74+
tutorial {
75+
id
76+
name
77+
}
78+
}
79+
bookmarked: userTutorials(where: { bookmarked: true }) {
80+
tutorial {
81+
id
82+
name
83+
}
84+
}
85+
progress: userTutorials(where: { currentChapter_not: 0 }) {
86+
tutorial {
87+
id
88+
name
89+
}
90+
}
91+
}
92+
}
93+
}
94+
`;

packages/gatsby-theme/src/utils/queries/markdown.tsx

-63
This file was deleted.

packages/gatsby-theme/src/utils/queries/profile.tsx

-33
This file was deleted.

packages/gatsby-theme/wrap-root-element.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from "react";
2-
import { MDXProvider } from "@mdx-js/react";
3-
import { preToCodeBlock } from "mdx-utils";
4-
import { ApolloProvider } from "react-apollo";
1+
import React from 'react';
2+
import { MDXProvider } from '@mdx-js/react';
3+
import { preToCodeBlock } from 'mdx-utils';
4+
import { ApolloProvider } from 'react-apollo';
55

6-
import { client } from "./src/Apollo";
6+
import { client } from './src/Apollo';
77

8-
import { Code } from "./src/components/code";
8+
import { Code } from './src/components/shared/code';
99

1010
// components is its own object outside of render so that the references to
1111
// components are stable
@@ -19,7 +19,7 @@ const components = {
1919
// it's possible to have a pre without a code in it
2020
return <pre {...preProps} />;
2121
}
22-
}
22+
},
2323
};
2424
export const wrapRootElement = ({ element }) => {
2525
return (

0 commit comments

Comments
 (0)