Skip to content

Query to return Array 2D #609

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

Closed
albertcito opened this issue Mar 23, 2020 · 2 comments
Closed

Query to return Array 2D #609

albertcito opened this issue Mar 23, 2020 · 2 comments
Labels

Comments

@albertcito
Copy link
Contributor

Versions:

  • graphql-laravel Version: 4.0.0
  • Laravel Version: 6.0
  • PHP Version: 7.3

Question:

I have a matrix in the DB, And I would like to return a Array 2D type. But as far as I know, I just can return a simple array, but not an array 2x2. This is the Cell type

type Cell {
  row: number,
  col: number,
}

I can return it as an array of Cell, but I don't know if is possible to return a Array 2D like this one:

[
    [{row:0, col: 0}, {row:0, col: 1}, {row:0, col: 2}],
    [{row:1, col: 0}, {row:1, col: 1}, {row:1, col: 2}]
]
@albertcito
Copy link
Contributor Author

Looks like GraphQL doesn't support it: graphql/graphql-spec#423

@mfn
Copy link
Collaborator

mfn commented Mar 23, 2020

Yes, this is one of the limitations. To emulate tuples you would need a separate type and give the fields names.

The other limitations is that you can't project a hash (in PHP: array with dynamic keys) either.

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

No branches or pull requests

2 participants