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

Return a JSON Array for List Return Types #342

Merged
merged 2 commits into from
May 9, 2022

Conversation

jocrau
Copy link
Contributor

@jocrau jocrau commented May 9, 2022

A root operation that returns a list returns a JSON array as result. For example, the definition

type Query {
  machines: [Machine]
}

should have an example response like

{
  "data": {
    "machines": [
      { "machineId":  1234 }
    ]
  }
}

but currently generates

{
  "data": {
    "machines": {
      "machineId":  1234
    }
  }
}

This PR fixes this, by checking whether the return type is a list. It also accounts for non-nullable values.

Copy link
Collaborator

@newhouse newhouse left a comment

Choose a reason for hiding this comment

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

Thanks! I may change this around a little but, but looks good

@newhouse newhouse merged commit 129a3c4 into anvilco:main May 9, 2022
@newhouse
Copy link
Collaborator

newhouse commented May 9, 2022

Published in 1.1.3

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

Successfully merging this pull request may close these issues.

2 participants