Skip to content

Commit 5b90b9b

Browse files
authored
Update README.md
1 parent 6e3ebbb commit 5b90b9b

File tree

1 file changed

+210
-0
lines changed

1 file changed

+210
-0
lines changed

README.md

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,216 @@ Access the application via your browser at `http://localhost:8000`.
6565
- Utilize the GraphQL API at /graphql to interact with the system programmatically. Refer to the API documentation for available queries and mutations.
6666
- To share a snippet, generate a shareable link and share it with other developers. They can access and discuss the snippet through the provided link.
6767

68+
## GraphQL Queries and Mutations
69+
70+
| Operation | Description | Example Usage |
71+
|-----------------------|-----------------------------------------------------|---------------------------------------------------------|
72+
| **Queries** | | |
73+
| `getUser` | Get user information by ID | `getUser(id: ID!): User` |
74+
| `getSnippet` | Get snippet by ID | `getSnippet(id: ID!): Snippet` |
75+
| `searchSnippets` | Search snippets based on filters | `searchSnippets(filters: SnippetFilters!): [Snippet]` |
76+
| `getAllTags` | Get a list of all available tags | `getAllTags: [String]` |
77+
| `getUserSnippets` | Get all snippets created by a user | `getUserSnippets(userID: ID!): [Snippet]` |
78+
| `getTopRatedSnippets` | Get top-rated snippets by star rating | `getTopRatedSnippets(limit: Int!): [Snippet]` |
79+
| `getSnippetComments` | Get comments associated with a snippet | `getSnippetComments(snippetID: ID!): [Comment]` |
80+
| **Mutations** | | |
81+
| `createUser` | Create a new user | `createUser(input: CreateUserInput!): User` |
82+
| `createSnippet` | Create a new snippet | `createSnippet(input: CreateSnippetInput!): Snippet` |
83+
| `updateSnippet` | Update an existing snippet | `updateSnippet(id: ID!, input: UpdateSnippetInput!): Snippet` |
84+
| `deleteSnippet` | Delete a snippet by ID | `deleteSnippet(id: ID!): Boolean` |
85+
| `addTagToSnippet` | Add a tag to a snippet | `addTagToSnippet(snippetID: ID!, tag: String!): Snippet` |
86+
| `removeTagFromSnippet` | Remove a tag from a snippet | `removeTagFromSnippet(snippetID: ID!, tag: String!): Snippet` |
87+
| `shareSnippet` | Generate a shareable link for a snippet | `shareSnippet(snippetID: ID!): String` |
88+
| `rateSnippet` | Rate a snippet with a star value | `rateSnippet(snippetID: ID!, rating: Int!): Snippet` |
89+
| `createComment` | Create a comment on a snippet | `createComment(snippetID: ID!, text: String!): Comment` |
90+
| `deleteComment` | Delete a comment by ID | `deleteComment(id: ID!): Boolean` |
91+
| `flagComment` | Flag a comment as inappropriate | `flagComment(commentID: ID!): Comment` |
92+
| `approveSnippet` | Approve a snippet pending review | `approveSnippet(snippetID: ID!): Snippet` |
93+
| `createReview` | Create a review for a snippet | `createReview(snippetID: ID!, rating: Int!, text: String!): Review` |
94+
| `updateReview` | Update an existing review | `updateReview(reviewID: ID!, rating: Int!, text: String!): Review` |
95+
| `deleteReview` | Delete a review by ID | `deleteReview(id: ID!): Boolean` |
96+
| `addCollaborator` | Add a collaborator to a snippet | `addCollaborator(snippetID: ID!, userID: ID!): Snippet` |
97+
| `removeCollaborator` | Remove a collaborator from a snippet | `removeCollaborator(snippetID: ID!, userID: ID!): Snippet` |
98+
| `forkSnippet` | Fork an existing snippet to create a new one | `forkSnippet(snippetID: ID!): Snippet` |
99+
| `tagSuggestion` | Suggest tags based on snippet content | `tagSuggestion(snippetID: ID!): [String]` |
100+
101+
## GraphQL
102+
103+
```graphql
104+
type User {
105+
id: ID!
106+
username: String!
107+
email: String!
108+
snippets: [Snippet]
109+
}
110+
111+
type Snippet {
112+
id: ID!
113+
title: String!
114+
description: String!
115+
code: String!
116+
language: String!
117+
tags: [String]
118+
owner: User!
119+
collaborators: [User]
120+
ratings: [Review]
121+
comments: [Comment]
122+
}
123+
124+
type Comment {
125+
id: ID!
126+
text: String!
127+
user: User!
128+
snippet: Snippet!
129+
}
130+
131+
type Review {
132+
id: ID!
133+
rating: Int!
134+
text: String!
135+
user: User!
136+
snippet: Snippet!
137+
}
138+
139+
type Collaborator {
140+
id: ID!
141+
user: User!
142+
snippet: Snippet!
143+
}
144+
145+
input CreateUserInput {
146+
username: String!
147+
email: String!
148+
# Other user input fields
149+
}
150+
151+
input CreateSnippetInput {
152+
title: String!
153+
description: String!
154+
code: String!
155+
language: String!
156+
tags: [String]
157+
}
158+
159+
input UpdateSnippetInput {
160+
title: String
161+
description: String
162+
code: String
163+
language: String
164+
tags: [String]
165+
}
166+
167+
type Query {
168+
getUser(id: ID!): User
169+
getSnippet(id: ID!): Snippet
170+
searchSnippets(filters: SnippetFilters!): [Snippet]
171+
getAllTags: [String]
172+
getUserSnippets(userID: ID!): [Snippet]
173+
getTopRatedSnippets(limit: Int!): [Snippet]
174+
getSnippetComments(snippetID: ID!): [Comment]
175+
# Other queries
176+
}
177+
178+
input SnippetFilters {
179+
tags: [String]
180+
language: String
181+
# Other filtering fields
182+
}
183+
184+
type Mutation {
185+
createUser(input: CreateUserInput!): User
186+
createSnippet(input: CreateSnippetInput!): Snippet
187+
updateSnippet(id: ID!, input: UpdateSnippetInput!): Snippet
188+
deleteSnippet(id: ID!): Boolean
189+
addTagToSnippet(snippetID: ID!, tag: String!): Snippet
190+
removeTagFromSnippet(snippetID: ID!, tag: String!): Snippet
191+
shareSnippet(snippetID: ID!): String
192+
rateSnippet(snippetID: ID!, rating: Int!): Snippet
193+
createComment(snippetID: ID!, text: String!): Comment
194+
deleteComment(id: ID!): Boolean
195+
flagComment(commentID: ID!): Comment
196+
approveSnippet(snippetID: ID!): Snippet
197+
createReview(snippetID: ID!, rating: Int!, text: String!): Review
198+
updateReview(reviewID: ID!, rating: Int!, text: String!): Review
199+
deleteReview(id: ID!): Boolean
200+
addCollaborator(snippetID: ID!, userID: ID!): Snippet
201+
removeCollaborator(snippetID: ID!, userID: ID!): Snippet
202+
forkSnippet(snippetID: ID!): Snippet
203+
tagSuggestion(snippetID: ID!): [String]
204+
# Other mutations
205+
}
206+
```
207+
208+
AND
209+
210+
```graphql
211+
type Query {
212+
# ... previous queries
213+
214+
getUserByUsername(username: String!): User
215+
getSnippetByTitle(title: String!): Snippet
216+
}
217+
218+
type Mutation {
219+
# ... previous mutations
220+
221+
deleteCollaborator(snippetID: ID!, userID: ID!): Snippet
222+
createTag(tagName: String!): String
223+
editUser(id: ID!, input: EditUserInput!): User
224+
editComment(id: ID!, newText: String!): Comment
225+
createFlaggedComment(snippetID: ID!, text: String!): Comment
226+
}
227+
228+
input EditUserInput {
229+
username: String
230+
email: String
231+
# Other user editable fields
232+
}
233+
234+
type Subscription {
235+
snippetCreated: Snippet
236+
commentAdded(snippetID: ID!): Comment
237+
reviewAdded(snippetID: ID!): Review
238+
}
239+
240+
type Comment {
241+
id: ID!
242+
text: String!
243+
user: User!
244+
snippet: Snippet!
245+
isFlagged: Boolean
246+
}
247+
248+
type FlaggedComment {
249+
id: ID!
250+
originalComment: Comment!
251+
reason: String!
252+
}
253+
254+
enum SortDirection {
255+
ASC
256+
DESC
257+
}
258+
259+
input SearchOptions {
260+
query: String!
261+
sortBy: String
262+
sortDirection: SortDirection
263+
limit: Int
264+
}
265+
266+
type SearchResult {
267+
items: [Snippet]
268+
totalCount: Int
269+
}
270+
271+
type Query {
272+
# ... previous queries
273+
274+
searchSnippetsWithOptions(options: SearchOptions!): SearchResult
275+
}
276+
```
277+
68278
## Contributing
69279

70280
- Contributions to the Code Snippet Manager project are welcome! To contribute:

0 commit comments

Comments
 (0)