107 | All nodes that implements NodeInterface are refetchable
108 |
109 |
110 |
111 |
112 | ---
113 |
114 |
121 |
122 | ---
123 |
124 |
154 | ---
155 |
156 | # What is a Cursor?
157 |
158 | A cursor is a pointer to a "list"/"connection", it tells you where you are in a list of items
159 |
160 | ---
161 |
162 | # Forward Pagination
163 |
164 | first: 10, after: "mycurrentcursor"
165 |
166 | This tell GraphQL to return 10 items after "mycurrentcursor" cursor
167 |
168 | ---
169 | # Backward Pagination
170 |
171 | last: 10, before: "anothercursor"
172 |
173 | This tell GraphQL to return 10 items before "anotercursor" cursor
174 |
175 | ---
176 |
177 | # Mutations
178 |
179 | - It should return all necessary data to update your GraphQL client
180 |
181 | ---
182 |
183 | # Mutations that add a new Node/Edge to the Graph
184 |
185 | - It should return the new created edge to be add to existing connections
186 |
187 | ---
188 |
189 |
206 | ---
207 |
208 | # Mutations that edit an existing Node
209 |
210 | - It should return the edited node
211 |
212 | ---
213 |
214 |
229 | ---
230 |
231 | # Mutation that remove a Node
232 |
233 | - It should return the id of removed node
234 |
235 | ---
236 |
237 |
250 | ---
251 |
252 | # Pratical GraphQL Tips
253 |
254 | This is based on our experience working with GraphQL since their public release at 2015
255 |
256 | ---
257 |
258 | ## Avoid Viewer
259 |
260 | - Viewer was a "hacky" solution for Relay Classic where you couldn't do query on QueryType
261 | - We recommend use fields directly on QueryType instead, so we can avoid confusion
262 |
263 | ---
264 |
265 | ## Keep Logged User on GraphQL Context
266 |
267 | - As soon as you know who is logged user, add it to your GraphQL context so you can easily access them in any resolver
268 | - This is also useful to implement viewer can see (security) solutions on resolver based level
269 |
270 | ---
271 |
272 | ## Add a me field resolver
273 |
274 | - me field on QueryType that resolves to a UserType of the logged user
275 | - This makes it easy to find out who is logged in your app
276 |
277 | ---
278 |
279 | ## Each Node should have a load function
280 |
281 | - Each type should have an unique way to be resolved
282 | - This will make sure that every resolver is always resolving the correct data
283 | - This also make sure it is easy to add dataloader later on
284 | - UserLoader.load(context, id)
285 |
286 | ---
287 |
288 | ## Create a Dataloader generator per database/resource
289 | - Check [GraphQL Mongoose Loader](https://github.com/entria/graphql-mongoose-loader#mongoose-dataloader-batch)
290 | - This make sure all data is resolved in the same way with all optimizations
291 |
292 | ---
293 |
294 | ## Create one Connection per database/resource cursor
295 | - Check [GraphQL Mongoose Connection](https://github.com/entria/graphql-mongoose-loader#connection-from-mongoose-cursor)
296 | - This make sure all your connections handle cursor and pagination properly
297 |
298 | ---
299 |
300 | ## Follow Relay Mutation Input/Output Object pattern
301 | - Check [graphql-relay](https://github.com/graphql/graphql-relay-js)
302 | - With an Input Object type in your mutation it is easy to add more fields without breaking old clients
303 | - The same goes to Output Object type
304 |
305 | ---
306 |
307 | ## References
308 |
309 | - [Relay Docs about GraphQL Server Specification](https://relay.dev/docs/en/graphql-server-specification)
310 | - [Object Identification](https://relay.dev/graphql/objectidentification.htm)
311 | - [Cursor Connections](https://relay.dev/graphql/connections.htm)
312 | - [Relay Mutations](https://relay.dev/graphql/mutations.htm)
313 |
314 | ---
315 |
316 | ## References
317 |
318 | - [Relay Mutations Guide](https://relay.dev/docs/en/mutations)
319 | - [Entria Playground](https://github.com/entria/entria-fullstack)
320 | - [GraphQL Relay 2015](https://pt-br.reactjs.org/blog/2015/02/20/introducing-relay-and-graphql.html)
321 | - [Building the New Facebook](https://developers.facebook.com/videos/2019/building-the-new-facebookcom-with-react-graphql-and-relay/)
322 | - [GraphQL Mongoose](https://github.com/entria/graphql-mongoose-loader#mongoose-dataloader-batch)
323 |
--------------------------------------------------------------------------------
/src/img/ast.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/ast.png
--------------------------------------------------------------------------------
/src/img/compilerParsing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/compilerParsing.png
--------------------------------------------------------------------------------
/src/img/compilerPipeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/compilerPipeline.png
--------------------------------------------------------------------------------
/src/img/compilerSteps.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/compilerSteps.png
--------------------------------------------------------------------------------
/src/img/entria.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/entria.png
--------------------------------------------------------------------------------
/src/img/entriaLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/entriaLogo.png
--------------------------------------------------------------------------------
/src/img/evergreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/evergreen.png
--------------------------------------------------------------------------------
/src/img/explorer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/explorer.png
--------------------------------------------------------------------------------
/src/img/github.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/github.png
--------------------------------------------------------------------------------
/src/img/graphql2ts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/graphql2ts.png
--------------------------------------------------------------------------------
/src/img/lisp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/lisp.png
--------------------------------------------------------------------------------
/src/img/me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/me.png
--------------------------------------------------------------------------------
/src/img/relayCompilerRepl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/relayCompilerRepl.png
--------------------------------------------------------------------------------
/src/img/relaymodern.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/relaymodern.png
--------------------------------------------------------------------------------
/src/img/syntatic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/syntatic.png
--------------------------------------------------------------------------------
/src/img/tokenizer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/tokenizer.png
--------------------------------------------------------------------------------
/src/img/tokens.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/tokens.png
--------------------------------------------------------------------------------
/src/img/traversal.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/traversal.gif
--------------------------------------------------------------------------------
/src/img/traverse.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/traverse.gif
--------------------------------------------------------------------------------
/src/img/twitter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/twitter.png
--------------------------------------------------------------------------------
/src/img/useState.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/useState.png
--------------------------------------------------------------------------------
/src/img/visitor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/src/img/visitor.png
--------------------------------------------------------------------------------
/src/theme.js:
--------------------------------------------------------------------------------
1 | import { dark as theme } from 'mdx-deck/themes'
2 |
3 | console.log('dark: ', theme);
4 |
5 | export default {
6 | ...theme,
7 |
8 | colors: {
9 | ...theme.colors,
10 | background: '#272425',
11 | },
12 | // Customize your presentation theme here.
13 | //
14 | // Read the docs for more info:
15 | // https://github.com/jxnblk/mdx-deck/blob/master/docs/theming.md
16 | // https://github.com/jxnblk/mdx-deck/blob/master/docs/themes.md
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/static/images/evergreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sibelius/practical-graphql-relay/f369503801cb1ae4aadf6cf100df909cd43fec75/static/images/evergreen.png
--------------------------------------------------------------------------------