Created
September 16, 2020 15:23
-
-
Save treystout/b92c393adf2010215d5a1e36d32f004b to your computer and use it in GitHub Desktop.
GQL query re-use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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