Skip to content

Conversation

@igdianov
Copy link
Collaborator

@igdianov igdianov commented May 5, 2019

This PR adds schema and query support for AND/OR list criteria expressions, i.e.

query {
  Authors(where: { 
    OR: [
      { name: { LIKE: "Anton" } } 
      { name: { LIKE: "Leo" } }
    ]
  }) {
    select {
      id
      name
    }
  } 
}

will return

{
  "data": {
    "Authors": {
      "select": [
        {
          "id": 1,
          "name": "Leo Tolstoy"
        },
        {
          "id": 4,
          "name": "Anton Chekhov"
        }
      ]
    }
  }
}

Also, using nested relations criterias:

  Books(where: { 
    author: {
      OR: [
        { name: { LIKE: "Anton" } } 
        { name: { LIKE: "Leo" } }
      ]
    }
  }) {
    select {
      id
      title
    }
  } 

will return:

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace"
        },
        {
          "id": 3,
          "title": "Anna Karenina"
        },
        {
          "id": 5,
          "title": "The Cherry Orchard"
        },
        {
          "id": 6,
          "title": "The Seagull"
        },
        {
          "id": 7,
          "title": "Three Sisters"
        }
      ]
    }
  }
}

See tests for more examples: https://github.com/introproventures/graphql-jpa-query/pull/134/files#diff-c7a89a97f801e55f37db13ebd434382c

@igdianov igdianov self-assigned this May 5, 2019
@codecov
Copy link

codecov bot commented May 5, 2019

Codecov Report

Merging #134 into master will decrease coverage by 0.51%.
The diff coverage is 73.28%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #134      +/-   ##
============================================
- Coverage     68.66%   68.15%   -0.52%     
- Complexity      415      428      +13     
============================================
  Files            33       33              
  Lines          2097     2201     +104     
  Branches        317      325       +8     
============================================
+ Hits           1440     1500      +60     
- Misses          531      569      +38     
- Partials        126      132       +6
Impacted Files Coverage Δ Complexity Δ
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 88.05% <100%> (ø) 119 <0> (ø) ⬇️
.../query/schema/impl/GraphQLJpaQueryDataFetcher.java 93.68% <100%> (ø) 23 <0> (ø) ⬇️
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 71.13% <71.77%> (-3.67%) 143 <25> (+13)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac7bda6...d5a55fe. Read the comment docs.

@igdianov igdianov force-pushed the igdianov-criteria-collections branch from 6c81110 to 6b7b562 Compare May 6, 2019 00:14
@igdianov igdianov force-pushed the igdianov-criteria-collections branch from 6b7b562 to d5a55fe Compare May 6, 2019 00:20
@igdianov igdianov merged commit 764c439 into master May 6, 2019
@igdianov igdianov deleted the igdianov-criteria-collections branch May 6, 2019 00: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.

2 participants