Skip to content

Instantly share code, notes, and snippets.

@treystout
Created September 16, 2020 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treystout/b92c393adf2010215d5a1e36d32f004b to your computer and use it in GitHub Desktop.
Save treystout/b92c393adf2010215d5a1e36d32f004b to your computer and use it in GitHub Desktop.
GQL query re-use
query LIST_ALL_MEMBERS(
$chapter_id: Int!,
$limit: Int = 20,
$offset: Int = 0
) {
users:chapter_members(
where: {
_and: [
{chapter_id: {_eq: $chapter_id}},
{is_chapter_organizer: {_eq: false}}
]
},
offset: $offset,
limit: $limit
) {
...MEMBER_FIELDS
}
meta:chapter_members_aggregate(
where: {
_and: [
{chapter_id: {_eq: $chapter_id}},
{is_chapter_organizer: {_eq: false}}
]
}
) {
aggregate {
count
}
}
}
# TODO: I have no idea how to re-use the body of LIST_ALL_MEMBERS, but I wish I did
query LIST_ALL_ORGANIZERS(
$chapter_id: Int!,
$limit: Int = 20,
$offset: Int = 0
) {
users:chapter_members(
where: {
_and: [
{chapter_id: {_eq: $chapter_id}},
{is_chapter_organizer: {_eq: true}}
]
},
offset: $offset,
limit: $limit
) {
...MEMBER_FIELDS
}
meta:chapter_members_aggregate(
where: {
_and: [
{chapter_id: {_eq: $chapter_id}},
{is_chapter_organizer: {_eq: true}}
]
}
) {
aggregate {
count
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment