Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds additional query syntax for the CDA #49

Merged
merged 20 commits into from
Jul 9, 2020

Conversation

floriank
Copy link
Collaborator

@floriank floriank commented Jul 5, 2020

After having no time for a while these days and thinking a bit about #38, I decided to put in some work about it.

This will add support for more complex queries as noted by @ryansch, in the form of:

Entries 
|> content_type("my_content_type") 
|> by(id: "my_id", number_of_warthogs: [lt: 42]) # or similar, no clue what offers the most benefits
|> fetch_all

and provide some safeguards around it, e.g. using by without a content_type call is not permitted, etc.

Feedback, as always, is very welcome.

TODO

  • Entries by content_type
  • Entries and Assets via by
  • Array support in by, via [nin] and [in]
  • Range support in by via [lte], [gte], [lt] and [gt]
  • Existence support
  • Full text support via query and [match]

Out of scope

  • Full text per field
  • Geolocation shenanigans
  • filtering by mime types

Somebody create some issues for the ones above please 馃槈 (will probably do tomorrow)

Fixes #38.

@floriank floriank self-assigned this Jul 5, 2020
@floriank floriank marked this pull request as draft July 5, 2020 11:00
@coveralls
Copy link

coveralls commented Jul 5, 2020

Pull Request Test Coverage Report for Build 1822167b055a772b4c6d481759eee4d9baa79915-PR-49

  • 41 of 48 (85.42%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+11.6%) to 79.412%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/contentful_delivery/delivery.ex 2 3 66.67%
lib/contentful/query.ex 19 25 76.0%
Totals Coverage Status
Change from base Build 50ea35dcac6ffacfcfa51f7ce5d8b4e222b16d5c: 11.6%
Covered Lines: 108
Relevant Lines: 136

馃挍 - Coveralls

@floriank floriank force-pushed the more-complex-queries branch 2 times, most recently from 44e140f to 8903f5c Compare July 5, 2020 14:01
@floriank floriank requested a review from asaaki July 5, 2020 15:27
lib/contentful/request.ex Outdated Show resolved Hide resolved
Copy link
Collaborator

@asaaki asaaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good. I'm not a query expert though. 馃槄
Just tiny nits.

lib/contentful/request.ex Outdated Show resolved Hide resolved
lib/contentful/request.ex Outdated Show resolved Hide resolved
lib/contentful/request.ex Outdated Show resolved Hide resolved
lib/contentful/query.ex Show resolved Hide resolved
..as part of actually writing the officially recognized X-Contentful-User-Agent Header
@floriank floriank requested a review from asaaki July 9, 2020 10:42
@floriank floriank marked this pull request as ready for review July 9, 2020 10:43
Copy link
Collaborator

@asaaki asaaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! 馃槏

@floriank floriank merged commit 43834a7 into contentful-userland:master Jul 9, 2020
@floriank floriank deleted the more-complex-queries branch July 9, 2020 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to build more complex queries?
4 participants