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

Conflicting grammar between Elide and Native GraphQL filterings? #3213

Closed
QubitPi opened this issue May 13, 2024 · 4 comments
Closed

Conflicting grammar between Elide and Native GraphQL filterings? #3213

QubitPi opened this issue May 13, 2024 · 4 comments

Comments

@QubitPi
Copy link
Contributor

QubitPi commented May 13, 2024

Expected Behavior

Hi Elide team, we are trying to fetch a person from database by ID.

We have a working native GraphQL query that looks like

query GetPerson($id:String!) {
  person(filter:$id) {
    edges {
      node {
        id
        name
      }
    }
  }
}

{
  "id": "12345"
}

We expect this query to work in Elide as well

Current Behavior

The query above, however, returns a RSQL parsing error, because it forces us to use RSQL syntax like

query GetPerson() {
  person(filter:"id==\"12345\"") {
    edges {
      node {
        id
        name
      }
    }
  }
}

In addition, variable substitution inside string doesn't seem to work as we was not able to put things like
person(filter:"id==${someId}") {

Possible Solution

We have a hack like this

query GetPerson($id:String!) {
  person(filter:$id) {
    edges {
      node {
        id
        name
      }
    }
  }
}

{
  "id": "id=='12345'"
}

But this makes our code non-portable by this non-Graphql syntax: "id": "id=='12345'" at the bottom and we are worried about more such conflicts which would complicate our developments in the future

There would be a much happier Elide user if Elide could transparently maps native GraphQL filtering to Elide's RSQL filtering, because at the end of the day, much more people are comfortable with native GraphQL than adapting a special syntax like RSQL

Steps to Reproduce (for bugs)

The documentation mentions a mandatory grammar of RSQL which aligns with what we see at runtime

Context

We have a frontend project using Apollo GraphQL to construct GraphQL query, specifically using useQuery.

It'd be much better if elide can accept whatever is produced by useQuery

Your Environment

  • Elide version used: 7.x
  • Environment name and version (Java 1.8.0_152): JDK 17
  • Operating System and version: Ubuntu 22.04
  • Link to your project: (This is an internal project. I'm sorry 🫤 )
@QubitPi QubitPi changed the title Conflicting grammar between Elide GraphQL filtering and Native GraphQL filtering? Conflicting grammar between Elide and Native GraphQL filterings? May 13, 2024
@justin-tay
Copy link
Collaborator

As far as I know the GraphQL specification doesn't have any standards regarding the query arguments, let alone the filter argument. Can you indicate where the specification defines this native GraphQL filtering?

I think you would typically manipulate string variables with javascript using template literals.

If you just want to query by id you could use the ids argument.

query GetPerson($ids:[String]) {
  person(ids:$ids) {
    edges {
      node {
        id
        name
      }
    }
  }
}

{
  "ids": ["12345"]
}

@QubitPi
Copy link
Contributor Author

QubitPi commented May 26, 2024

Hi @justin-tay , thank you for the reply.

Sorry for the confusion. What we mean by "filtering" actually turned out to be "argument". Thanks.

We have tried your query which, however, gives back an error of:

page 2

The data model that gives the error above is:

@Entity
@Table(name = "person")
@Include(rootLevel = true, name = "person", description = "person", friendlyName = "person")
public class Person {

    /**
     * Surrogate key.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public long id;

    /**
     * The person's legal name.
     */
    public String name;
}

@justin-tay
Copy link
Collaborator

Does a person entity with that id exist? If it doesn't exist I think this is the expected behavior.

@QubitPi
Copy link
Contributor Author

QubitPi commented May 26, 2024

Does a person entity with that id exist? If it doesn't exist I think this is the expected behavior.

That ID doesn't exist yet.

I looked up GraphQL Spec which basically merits what you just said. I will close this issue then.

Thanks, Justin

@QubitPi QubitPi closed this as completed May 26, 2024
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