Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
hax.js
type Query = {
book(id: ID!): Book!
author(id: ID!): Author!
}
type Book = {
id: ID!
name: String
author: Author
}
type Author = {
id: ID!
name: String
books: [Book!]
}
{
book(id: 123) {
id
name
author {
id
name
}
}
}
// next page: click author
{
author(id: 123) [
id
name
books {
id
name
}
}
}
// cache
{
schema: ...,
resolvers: {
book: (cache, { id }) => cache.resolve({ __typename: 'Book', id }),
author: (cache, { id }) => cache.resolve({ __typename: 'Author', id })
}
}
// resolve
{
author: {
id: 123,
name: '',
books: null
}
}
// now i can actually fetch
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.