Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 0080a19

Browse files
committed
chore(framents): extract fragments
1 parent b76e2cf commit 0080a19

File tree

25 files changed

+930
-307
lines changed

25 files changed

+930
-307
lines changed

containers/AccountViewer/schema.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
11
import gql from 'graphql-tag'
2+
import { P } from '../schemas'
23

34
const user = gql`
4-
query user($id: ID!) {
5-
user(id: $id) {
6-
nickname
7-
avatar
8-
bio
9-
fromGithub
10-
location
11-
qq
12-
weibo
13-
weichat
14-
sex
15-
githubProfile {
16-
htmlUrl
17-
login
18-
}
19-
contributes {
20-
date
21-
count
22-
}
23-
}
24-
}
5+
${P.user}
256
`
267

278
const account = gql`

containers/CategorySetter/schema.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import gql from 'graphql-tag'
2+
import { F } from '../schemas'
23

34
const pagedCategories = gql`
45
query($filter: PagedFilter!) {
@@ -12,17 +13,12 @@ const pagedCategories = gql`
1213
title
1314
}
1415
author {
15-
id
16-
nickname
17-
avatar
16+
${F.author}
1817
}
1918
insertedAt
2019
updatedAt
2120
}
22-
pageNumber
23-
pageSize
24-
totalCount
25-
totalPages
21+
${F.pagedCounts}
2622
}
2723
}
2824
`

containers/CommunitiesContent/schema.js

Lines changed: 9 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,40 @@
11
import gql from 'graphql-tag'
2-
3-
const pagedCommunitiesRaw = `
4-
query($filter: PagedFilter!) {
5-
pagedCommunities(filter: $filter) {
6-
entries {
7-
id
8-
title
9-
desc
10-
raw
11-
logo
12-
subscribersCount
13-
categories {
14-
id
15-
title
16-
}
17-
threads{
18-
id
19-
title
20-
raw
21-
}
22-
insertedAt
23-
updatedAt
24-
}
25-
pageNumber
26-
pageSize
27-
totalCount
28-
totalPages
29-
}
30-
}
31-
`
2+
import { P, F } from '../schemas'
323

334
const pagedCommunities = gql`
34-
${pagedCommunitiesRaw}
5+
${P.pagedCommunities}
356
`
367
const pagedCategories = gql`
378
query($filter: PagedFilter!) {
389
pagedCategories(filter: $filter) {
3910
entries {
40-
id
41-
title
42-
raw
11+
${F.category}
4312
communities {
4413
id
4514
logo
4615
title
4716
}
4817
author {
49-
id
50-
nickname
51-
avatar
52-
}
53-
insertedAt
54-
updatedAt
55-
}
56-
pageNumber
57-
pageSize
58-
totalCount
59-
totalPages
60-
}
61-
}
62-
`
63-
64-
const pagedTagsRaw = `
65-
query($filter: PagedFilter!) {
66-
pagedTags(filter: $filter) {
67-
entries {
68-
id
69-
title
70-
color
71-
thread
72-
community {
73-
id
74-
logo
75-
title
76-
}
77-
topic {
78-
title
79-
raw
18+
${F.author}
8019
}
8120
insertedAt
8221
updatedAt
8322
}
84-
pageNumber
85-
pageSize
86-
totalCount
87-
totalPages
88-
}
89-
}
90-
`
91-
const pagedThreadsRaw = `
92-
query($filter: PagedFilter!) {
93-
pagedThreads(filter: $filter) {
94-
entries {
95-
id
96-
title
97-
raw
98-
}
99-
totalCount
100-
totalPages
101-
pageSize
102-
pageNumber
23+
${F.pagedCounts}
10324
}
10425
}
10526
`
106-
10727
const pagedTags = gql`
108-
${pagedTagsRaw}
28+
${P.pagedTags}
10929
`
110-
11130
const pagedThreads = gql`
112-
${pagedThreadsRaw}
31+
${P.pagedThreads}
11332
`
114-
11533
const pagedPosts = gql`
116-
query($filter: PagedArticleFilter) {
117-
pagedPosts(filter: $filter) {
118-
entries {
119-
id
120-
title
121-
digest
122-
author {
123-
id
124-
nickname
125-
avatar
126-
}
127-
communities {
128-
id
129-
title
130-
logo
131-
raw
132-
}
133-
tags {
134-
id
135-
title
136-
color
137-
thread
138-
community {
139-
id
140-
}
141-
}
142-
commentsCount
143-
commentsParticipatorsCount
144-
views
145-
favoritedCount
146-
starredCount
147-
insertedAt
148-
updatedAt
149-
}
150-
totalCount
151-
pageSize
152-
pageNumber
153-
}
154-
}
34+
${P.pagedPosts}
15535
`
15636
const pagedJobs = gql`
157-
query pagedJobs($filter: PagedArticleFilter) {
158-
pagedJobs(filter: $filter) {
159-
entries {
160-
id
161-
title
162-
company
163-
companyLogo
164-
location
165-
desc
166-
body
167-
insertedAt
168-
updatedAt
169-
views
170-
author {
171-
id
172-
nickname
173-
avatar
174-
}
175-
communities {
176-
id
177-
title
178-
logo
179-
raw
180-
}
181-
tags {
182-
id
183-
title
184-
color
185-
thread
186-
community {
187-
id
188-
}
189-
}
190-
}
191-
totalCount
192-
pageSize
193-
pageNumber
194-
}
195-
}
37+
${P.pagedJobs}
19638
`
19739

19840
const deleteCommunity = gql`
@@ -265,11 +107,8 @@ const deleteCategory = gql`
265107

266108
const schema = {
267109
pagedCommunities,
268-
pagedCommunitiesRaw,
269110
pagedTags,
270-
pagedTagsRaw,
271111
pagedThreads,
272-
pagedThreadsRaw,
273112
pagedCategories,
274113
pagedPosts,
275114
pagedJobs,

containers/Sidebar/MenuList.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react'
2+
3+
import CommunityMenuItem from './CommunityMenuItem'
4+
import CommunitiesRootMenuItem from './CommunitiesRootMenuItem'
5+
import UsersRootMenuItem from './UsersRootMenuItem'
6+
7+
import { MenuItem } from './styles/menu'
8+
9+
import { uid } from '../../utils'
10+
11+
const MenuList = ({ items, activeRaw, activeThread }) => (
12+
<MenuItem>
13+
<CommunitiesRootMenuItem
14+
activeRaw={activeRaw}
15+
activeThread={activeThread}
16+
/>
17+
<UsersRootMenuItem activeRaw={activeRaw} activeThread={activeThread} />
18+
19+
{items.map(item => (
20+
<CommunityMenuItem
21+
key={uid.gen()}
22+
item={item}
23+
activeRaw={activeRaw}
24+
activeThread={activeThread}
25+
/>
26+
))}
27+
</MenuItem>
28+
)
29+
30+
export default MenuList

containers/ThreadSetter/schema.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
import gql from 'graphql-tag'
2+
import { F, P } from '../schemas'
23

34
const pagedThreads = gql`
4-
query($filter: PagedFilter!) {
5-
pagedThreads(filter: $filter) {
6-
entries {
7-
id
8-
title
9-
raw
10-
}
11-
totalCount
12-
totalPages
13-
pageSize
14-
pageNumber
15-
}
16-
}
5+
${P.pagedThreads}
176
`
187
const setThread = gql`
198
mutation($communityId: ID!, $threadId: ID!) {
209
setThread(communityId: $communityId, threadId: $threadId) {
2110
id
2211
threads {
23-
title
12+
${F.thread}
2413
}
2514
}
2615
}

0 commit comments

Comments
 (0)