Closed QubitPi closed 5 months ago
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"]
}
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:
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;
}
Does a person entity with that id exist? If it doesn't exist I think this is the expected behavior.
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
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
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
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
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 futureThere 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