New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make entityQuery filtering and sorting more flexible #421

Closed
pmelab opened this Issue Oct 26, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@pmelab
Copy link
Contributor

pmelab commented Oct 26, 2017

EntityQuery could use the same concept of "fancy filters" as JSON API does, and even share the code.

https://gist.github.com/e0ipso/efcc4e96ca2aed58e32948e4f70c2460

@pmelab

This comment has been minimized.

Copy link
Contributor

pmelab commented Oct 26, 2017

/cc @e0ipso

@ivanjaros

This comment has been minimized.

Copy link

ivanjaros commented Oct 26, 2017

Looks interesting but:
I have a custom per-type-entity query that has entity-specific sorting(ie. sort only on fields attached to the entity type) and conditions(apply condition only to fields attached to the entity type).

This requires a lot of derivers.

Looking at that proposal I cannot imagine being able to make the conditions and sorts entity-type-specific since the design allows grouping and nesting and whatnot. So I assume the developer would have to know the fields from another source and not directly from schema.

@pmelab

This comment has been minimized.

Copy link
Contributor

pmelab commented Oct 26, 2017

Yes, we would need to figure out typing. But it think even untyped this could be beneficial.

@ivanjaros

This comment has been minimized.

Copy link

ivanjaros commented Oct 26, 2017

Looking at the original structure, that is actually quite doable. The second proposal(last comment) is a bit scary.

@e0ipso

This comment has been minimized.

Copy link

e0ipso commented Nov 9, 2017

Excited to see progress on this already! I lack implementation knowledge in this project but I have some GraphQL familiarity and a lot of familiarity with Fancy Filters.

Ping me if you think I can help.

@fubhy fubhy changed the title Add JSON API's fancy filters to EntityQuery Make entityQuery filtering and sorting more flexible Jan 25, 2018

@fubhy fubhy closed this Feb 9, 2018

@fubhy

This comment has been minimized.

Copy link
Contributor

fubhy commented Feb 9, 2018

@fubhy

This comment has been minimized.

Copy link
Contributor

fubhy commented Feb 9, 2018

Merged!

This now allows queries like e.g. this:

{
  nodeQuery(filter: {
    conjunction: AND
    conditions: [{
      field: "nid"
      value: ["1", "10"]
      operator: BETWEEN
    }]
    groups: [{
      conjunction: OR
      conditions: [{
        field: "title"
        value: ["graphql filtering rocks"]
      }, {
        field: "title"
        value: ["graphql is awesome"]
        operator: LIKE
      }, {
        field: "uid"
        value: ["1"]
      }],
      groups: [{
        conjunction: AND
        conditions: [{
          field: "field_tags.target_id"
          value: ["1"]
        }]
      }]
    }]
  }, sort: [{
    field: "nid"
    direction: ASC
  }, {
    field: "uid"
    direction: DESC
  }]) {
    entities {
      entityUuid
      entityBundle
      entityPublished
      entityType
      entityChanged
      entityId
      entityCreated
      entityLabel
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment