Skip to content

feat: support enum variable bindings in queries #109

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

Merged
merged 1 commit into from
Apr 16, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Apr 16, 2019

Given variables json:

{
  "genres": "NOVEL"
}

And the query with enum variable bindings:

query($genre: Genre) {
  Books(where: {
    genre: {EQ: $genre}
  }) {
    select {
      id
      title
      genre
    }
  }
}

Will return:

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace",
          "genre": "NOVEL"
        },
        {
          "id": 3,
          "title": "Anna Karenina",
          "genre": "NOVEL"
        }
      ]
    }
  }
}

And given variables json:

{
  "genres": ["NOVEL"]
}

And the query with enum list variable bindings:

query($genres: [Genre!]) {
  Books(where: {
    genre: {IN: $genres}
  }) {
    select {
      id
      title
    }
  }
}

will result:

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace"
        },
        {
          "id": 3,
          "title": "Anna Karenina"
        }
      ]
    }
  }
}

And given variables json:

{
  "genre": "NOVEL"
}

And query with single enum to enum list variable binding:

query($genre: Genre!) {
  Books(where: {
    genre: {IN: [$genre]}
  }) {
    select {
      id
      title
    }
  }
}

Will result in

{
  "data": {
    "Books": {
      "select": [
        {
          "id": 2,
          "title": "War and Peace"
        },
        {
          "id": 3,
          "title": "Anna Karenina"
        }
      ]
    }
  }
}

@igdianov igdianov self-assigned this Apr 16, 2019
@codecov
Copy link

codecov bot commented Apr 16, 2019

Codecov Report

Merging #109 into master will increase coverage by 0.05%.
The diff coverage is 92.3%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #109      +/-   ##
============================================
+ Coverage     65.75%   65.81%   +0.05%     
- Complexity      366      368       +2     
============================================
  Files            37       37              
  Lines          2015     2024       +9     
  Branches        297      299       +2     
============================================
+ Hits           1325     1332       +7     
  Misses          562      562              
- Partials        128      130       +2
Impacted Files Coverage Δ Complexity Δ
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 71.91% <92.3%> (-0.14%) 113 <1> (+2)
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 86.64% <0%> (+0.18%) 103% <0%> (ø) ⬇️

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 8e9d409...d418513. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Apr 16, 2019

Codecov Report

Merging #109 into master will increase coverage by 0.05%.
The diff coverage is 92.3%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #109      +/-   ##
============================================
+ Coverage     65.75%   65.81%   +0.05%     
- Complexity      366      368       +2     
============================================
  Files            37       37              
  Lines          2015     2024       +9     
  Branches        297      299       +2     
============================================
+ Hits           1325     1332       +7     
  Misses          562      562              
- Partials        128      130       +2
Impacted Files Coverage Δ Complexity Δ
...a/query/schema/impl/QraphQLJpaBaseDataFetcher.java 71.91% <92.3%> (-0.14%) 113 <1> (+2)
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 86.64% <0%> (+0.18%) 103% <0%> (ø) ⬇️

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 8e9d409...d418513. Read the comment docs.

@igdianov igdianov merged commit 5dd999a into master Apr 16, 2019
@igdianov igdianov deleted the igdianov-enum-variables branch April 16, 2019 02:02
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.

1 participant