bobbyt
12/28/2017, 8:51 PMexport const CURRENT_USER_QUERY = gql`
query currentUserQuery {
user {
...UserFragment,
}
}
${USER_FRAGMENT}
`;
And here is the USER_FRAGMENT
portion:
const USER_FRAGMENT = gql`
fragment UserFragment on User {
id
username
friends {
id
username
chatGroups(filter: { users_some: { id: *_[CURRENT USER QUERY ID]_* }}) {
id
users {
id
username
}
}
}
}
`;
export default USER_FRAGMENT;
Since a friend
can belong to many chat groups I only want to return the chat groups that contain the current user as well as the friend (using the users_some
filter). I don’t want to have to pass a userId variable to the query since it’s authenticated.
Is this possible? Thanks in advance!matic
12/28/2017, 11:22 PMbobbyt
12/29/2017, 4:03 PMmatic
12/29/2017, 4:26 PMuserId
on the client side and include it in the queries, but that’s just as far as it gets right now, hope it helps you in any way 🙂bobbyt
12/29/2017, 6:02 PMuser
) query, I don't pass any parameters into the query itself, so looking for a way to dynamically use the authenticated user's id to filter on the subfield chatGroups
. Or must I upgrade from the legacy console and construct my own resolver? Thanks!