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

Include aliases in query plan #1072

Open
crissi opened this issue Feb 16, 2022 · 5 comments
Open

Include aliases in query plan #1072

crissi opened this issue Feb 16, 2022 · 5 comments

Comments

@crissi
Copy link
Contributor

crissi commented Feb 16, 2022

Running lookAhead with queryplan with this query:

$resolveInfo->lookAhead(['group-implementor-fields'])->queryPlan();
query  {
  caseById(id: 7317) {
    default: schemesCount
    closed: schemesCount(status: CLOSED)
    approved: schemesCount(status: APPROVED)
  }
}

Gives us:

{
  "fields": {
    "schemesCount": {
      "type": "Int",
      "fields": [],
      "args": {
        "status": "APPROVED"
      }
    }
  }
}

I suspect all fields should be included somehow in the result!

@spawnia
Copy link
Collaborator

spawnia commented Feb 16, 2022

I think the purpose of the query plan is to allow the server to make decisions on how to resolve the query efficiently. Given aliases are given by the client and transparently handled by the execution engine of this library, they do not seem useful to include.

@crissi
Copy link
Contributor Author

crissi commented Feb 16, 2022

yes, but since each alias can have different arguments like in my example.

Here it just returns the argument of the last schemesCount property.

@spawnia spawnia reopened this Feb 16, 2022
@spawnia
Copy link
Collaborator

spawnia commented Feb 16, 2022

Right, that is misleading. args should really be a list with multiple args passed to the different aliases - same with fields actually. Perhaps a better structure would be:

{
  "fields": {
    "schemesCount": {
      "type": "Int",
      "aliases": [
        {
          "fields": [],
          "args": {}
        },
        {
          "fields": [],
          "args": {
            "status": "APPROVED"
          }
        },
        {
          "fields": [],
          "args": {
            "status": "CLOSED"
          }
        },
      ]
    }
  }
}

@spawnia spawnia changed the title include aliases in query plan Include aliases in query plan Feb 16, 2022
@crissi
Copy link
Contributor Author

crissi commented Feb 16, 2022

maybe include the alias name in there for good measure

@jeroenschieven
Copy link

We are having the same issue. We use the queryPlan to dynamically build an ElasticSearch query. Some fields have quite some possible arguments, therefore we want to be able to alias those fields.

Unfortunately, the only alternative for now is duplicating these fields.

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

No branches or pull requests

3 participants