Reduction
type Query {
root(context: Context!): Root!
}
input Context {
user: User!
}
input User {
id: String!
name: String!
email: String!
}
type Root {
showNewEditor: Boolean!
}Partial reduction
Last updated
type Query {
root(context: Context!): Root!
}
input Context {
user: User!
}
input User {
id: String!
name: String!
email: String!
}
type Root {
showNewEditor: Boolean!
}Last updated
Query {
root: ({ context }) => Root {
showNewEditor: ({}) =>
if (
context.user.id in ["user_123", "user_456"] AND
context.user.email endsWith "@test.com"
) {
true
} else {
false
}
}
}query TestQuery {
root(
context: {
user: {
id: "user_123"
name: "Test"
email: "[email protected]"
}
}
) {
showNewEditor
}
}Query {
root: Root {
showNewEditor: true
}
}{
"__typename": "Query",
"root": {
"__typename": "Root",
"showNewEditor": false
}
}query TestQuery {
root(
context: {
user: {
id: "user_123"
}
}
) {
showNewEditor
}
}Query {
root: ({ context }) => Root {
showNewEditor: ({}) =>
if (true AND context.user.email endsWith "@test.com") {
true
} else {
false
}
}
}