Skip to content

Instantly share code, notes, and snippets.

@sorenbs
Created January 2, 2017 14:30
Show Gist options
  • Save sorenbs/dec072b8b4df0ab6cbd441861a53eaf9 to your computer and use it in GitHub Desktop.
Save sorenbs/dec072b8b4df0ab6cbd441861a53eaf9 to your computer and use it in GitHub Desktop.

API

field_every: FilterCondition # condition must be true for all nodes
field_some: FilterCondition # condition must be true for at least 1 node
field_none: FilterCondition # condition must be false for all nodes
field_is_null: Boolean # is the relation field null

Examples

# Get all Friends that are not in Group A and not in Group B and attend Event X

User(id: me){
  friends(filter:{AND: [
    {groups_every: {id_not: "group-a-id"}},
    {groups_every: {id_not: "group-b-id"}},
    {attended_some: {id: "event-x-id"}}
  ]})
}

# Get all Users that are in two groups A and B where the current user is also a member of A and B

allUsers(filter:{AND:[
  {groups_every: {id: "group-a-id", members_some: {id_neq: "current-user-id"}}},
  {groups_every: {id: "group-v-id", members_some: {id_neq: "current-user-id"}}}
]})

# All pictures where the author is not my friend.

allPictures(filter: { author { friends_every: { id_not: “my_id” } } })

# All pictures without author.

allPictures(filter: { author_is_null: true })

# All pictures with author.

allPictures(filter: { author_is_null: false })
@philcockfield
Copy link

@sorenbs, oh - I think that would actually work fine as I'd really just to want to go a few levels deep, then re-query if the user ended up digging deeper in the UI.

Super cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment