This project practices README-driven development
Add common functionality to Apollo local state via clientside schema directives.
import restated from 'apollo-client-restated'
const schema = makeExecutableSchema({
typeDefs,
schemaDirectives: {
restated,
}
})
type Query {
page: Int! @restated(default: 1, actions: [INCREMENT, DECREMENT])
}
# GENERATED
type Mutation {
pageIncrement
pageDecrement
}
type Query {
visible: Boolean! @restated(default: false, actions: [TOGGLE])
}
# GENERATED
type Mutation {
visibleToggle
}
type Query {
name: String @restated(actions: [SET])
}
# GENERATED
type Mutation {
nameSet(name: String)
}
type Query {
sign: String @restated(actions: [INVERT])
}
# GENERATED
type Mutation {
signInvert
}
const schema = makeExecutableSchema({
typeDefs,
schemaDirectives: {
restated({
invert: sign => -sign,
}),
}
})