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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QueryBuilder: How to build nested queries? #36

Open
deiga opened this issue Mar 4, 2021 · 1 comment
Open

QueryBuilder: How to build nested queries? #36

deiga opened this issue Mar 4, 2021 · 1 comment

Comments

@deiga
Copy link

deiga commented Mar 4, 2021

Most GQL APIs have nested objects and I'm puzzled by how to build these queries.
Here is an example of getting trying to get Pull Requests from the Github API:

String queryString = DSL.buildQuery {
    query('repository', [owner: 'foobar', name: 'baz']) {
      returns {
        query('pullRequests', [first: 10, headRefName: 'master', state: ['OPEN']]) {
          returns {
            totalCount
          }
        }
      }
    }
  }

But this generates a string like "{ pullRequests (first: 10,headRefName: \"master\",state: [OPEN]) { \n \ttotalCount\n } \n repository (owner: \"foobar\",name: \"baz\") { \n } \n }"
Which is clearly incorrect. I tried without the returns for the upper query, but it's a required field

@mariogarcia
Copy link
Contributor

@deiga I'll look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants