Chapter 10: Interacting with GraphQL APIs

  1. In the GitHub GraphQL Explorer, create a query to return the last five open issues in the React project. Return the issue title and the URL in the response:
query { 
repository (owner:"facebook", name:"react") {
issues(last: 5, states:[OPEN]) {
edges {
node {
title
url
}
}
}
}
}
  1. Enhance the last query, make the number of issues that is returned a parameter, and make this default to 5:
query ($lastCount: Int = 5) { 
repository (owner:"facebook", name:"react") {
issues(last: $lastCount, states: [OPEN]) {
edges {
node {
title
url
}
}
}
}
}
  1. Create a mutation in the GitHub GraphQL Explorer to unstar a starred repository. The mutation should take a repository ID as a parameter:
mutation ($repoId: ID!) {
removeStar(input: { starrableId: $repoId }) {
starrable {
stargazers {
totalCount
}
}
}
}
  1. What part of the HTTP request does the GraphQL query go in?

The HTTP body

  1. What part of the HTTP request does the GraphQL mutation go in?

The HTTP body

  1. How can we make the response from the react-apollo Query component type safe?

Create another component that extends Query passing in a type for the result as a generic parameter:

class MyQuery extends Query<IResult> {}

We can then use the MyQuery component in our JSX.

  1. Is caching on or off by default when you scaffold a project with react-boost?

On

  1. What prop can we use on the Mutation component to update the local cache?

The update prop.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.89.18