This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | async function fetchAndUpdatePosts() { | |
| const posts = await fetchPosts().catch(() => { | |
| console.log('error in fetching posts'); | |
| }); | |
| if (posts) { | |
| doSomethingWithPosts(posts); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | async function fetchAndUpdatePosts() { | |
| let posts; | |
| try { | |
| posts = await fetchPosts(); | |
| doSomethingWithPosts(posts); // throws an error | |
| } catch { | |
| // Now it handles errors from fetchPosts and doSomthingWithPosts. | |
| console.log('error in fetching posts'); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function fetchAndUpdatePosts() { | |
| fetchPosts() | |
| .then((posts) => { | |
| updatePosts(posts) | |
| .catch((err) => { | |
| console.log('error in updating posts'); | |
| }); | |
| }) | |
| .catch(() => { | |
| console.log('error in fetching posts'); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | async function fetchAndUpdatePosts() { | |
| let posts; | |
| try { | |
| posts = await fetchPosts(); | |
| } catch { | |
| console.log('error in fetching posts'); | |
| } | |
| if (!posts) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type RemovePostPayload { | |
| removedPost: Post | |
| removedComments: CommentConnection | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type Mutation { | |
| removePost(id: ID!): RemovePostPayload! | |
| } | |
| type RemovePostPayload { | |
| removedPost: Post | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "data": { | |
| "removePost": { | |
| "id": "UG9zdDo1Y2ZiZjZjNmE2OWU5NDc2OGQ5ODQ1Mzc=", | |
| "title": "What is GraphQL", | |
| } | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | type Mutation { | |
| removePost(id: ID!): Post | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "data": { | |
| "posts": { | |
| "pageInfo": { | |
| "hasNextPage": true, | |
| "hasPreviousPage": false | |
| }, | |
| "edges": [ | |
| { | |
| "cursor": "5cfbf6c6a69e94768d984537", | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | query PostsQuery { | |
| posts(first: 1) { | |
| pageInfo { | |
| hasNextPage | |
| hasPreviousPage | |
| } | |
| edges { | |
| cursor | |
| node { | |
| id | 
NewerOlder