-
Notifications
You must be signed in to change notification settings - Fork 859
Filter nodes based on related aggregations #110
Comments
Related to #70. |
I need to be able to query for all objects (lets say Cars) that do not have an owner (User) relation set. I'm not sure of the best syntax:
|
I think for to-one relations this syntax would work best: {
allCars(
filter: {
owner: null
}
) {
id
}
} and for to-many: {
allOwners(
filter: {
cars: []
}
) {
id
}
} |
@kabriel, it's now possible to query nodes that are not related in a to-one relation: {
noOwner: allCars(
filter: {
owner: null
}
) {
id
}
someOwner: allCars(
filter: {
owner_not: null
}
) {
id
}
} |
workaround is slightly varied checks based on nesting level and ways to check... persons: allPersons(
filter:{
verified: false
${valid ? `, avatar: {id_not:null}, name_not: "", bio_not: null, bio_not: "", user: {id_not:null}` : ''}
${invalid ? `, OR: [{avatar: {id: null}}, {name: ""}, {bio: null}, {user: {id: null}}]` : ''}
}
, first: ${pageSize}
, skip: ${pageSize * page}
, orderBy: ${orderBy}
) |
@matthiasak the syntax is |
I did. avatar_not was giving errors
Cheers,
Matt Keas
http://mkeas.org
…On Apr 25, 2017 3:43 AM, "Nilan Marktanner" ***@***.***> wrote:
@matthiasak <https://github.com/matthiasak> the syntax is avatar: null
and avatar_not: null. Did you try that?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/graphcool/feature-requests/issues/110#issuecomment-296961670>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA2-p6Uic2r2ijA-pcDkuhpvsfMvCa2Xks5rzbI0gaJpZM4MG5iF>
.
|
Please create a issue report here: https://github.com/graphcool/api-bugs/issues 🙂 |
Thanks to @mewdriller for this workaround to query nodes that are not connected in a to-many relation: {
allOwners(
filter: {
cars_every: {
id: "-1"
}
}
) {
id
}
} |
The following syntax seems to be working now for filtering nodes that are not connected in a to-many relation: {
allOwners(
filter: {
cars_every: {
id: null
}
}
) {
id
}
} And to do the opposite (filter nodes that have connections in a to-many relation), this is working: {
allOwners(
filter: {
cars_some: {
id_not: null
}
}
) {
id
}
}
This is the right way to do it, comparing id to |
Remove unused code from init command
Thank you for this great suggestion! Please have a look in the spec proposal to see if all your needs are met:-) https://github.com/graphcool/framework/issues/1279 |
I came across this problem today as well. I have a data model that looks something like: type User {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
emailAndPassAuth: EmailAndPasswordAuth @relation(name: "UserEmailAndPassAuth", onDelete: CASCADE)
# githubAuth: GithubAuth
# etc...
}
type EmailAndPasswordAuth {
id: ID! @unique
email: String! @unique
passwordHashed: String!
user: User! @relation(name: "UserEmailAndPassAuth")
} Now, I get a new login attempt with an email and a password. I can find the corresponding |
@samuela - I might be missing something obvious, so please let me know if I am :-) Can you not do a single query like this? query {
EmailAndPasswordAuths(where: email: $email, passwordHashed: $password) {
user {
id
}
}
} |
@sorenbs Ah, so it is a little bit trickier than that because the salt is also contained in
I came across this issue after a bit of googling about the problem, but on further inspection it looks like this may not be immediately relevant to the issue in this thread, so I'd be happy to move this elsewhere if you think that makes sense. |
I'd like to add a few more pragmas for filtering. Currently we can filter a direct entity for certain
in
,contains
,startsWith
, etc filters, like:But, we can't make a query on allGroups filtering by metadata or aggregates. One idea is to enable special filters that test sub-entities such as the below example query where I would like to filter for groups who have atleast 1 member
The text was updated successfully, but these errors were encountered: