I have that query in GraphQL
query getUserByName($name: String!) {
user(name: $name) {
id
name
email
}
}
I want to get all users that contains Jon in name
, not equal.
How can I modify the query to do contains please (without edit the server side)
Unfortunately, the question you're asking is impossible to answer. It is possible that you misunderstand what GraphQL is, so I'll suggest: think of GraphQL like you would think of REST. This isn't the perfect analogy, but pretending it was, I'll rephrase your question using REST:
I have a REST API. I am making this curl request:
curl -X GET "https://api.example.com/users?name=Jon"
I want to get all users that contains Jon in name, not equal.
How can I modify the request to do contains please (without edit the server side)
Obviously the answer to this question would be
I have no idea. The only person who can answer this is the person who created your REST API. If, however, they're using some library or framework on top of the REST, that particular framework may have pre-defined rules on how to do what you're asking. Unfortunately, 'it is REST' means very little, because literally anything could be happening behind the scenes, as long as it has the properties of a REST API (client-server architecture, stateless operations, cacheability, a uniform interface, layered system, and optionally, code-on-demand).
GraphQL is a query language for an API (like REST), and an API can do ANYTHING. It is not a query language for data (like SQL).
As a deeper example, from what you've defined here, what follows are a valid GraphQL Schema and a valid JavaScript resolver of that data:
type Anxiety {
id: Float
name: Boolean
email: Int
}
type Query {
user(name: String): Anxiety
}
const resolvers = {
Query: {
user: () => {
return { id: Math.PI, name: false, email: 5987319 };
}
}
}
Note that from this code, it is impossible to do what you're asking for. I don't have any functionality that looks anything up in any database. I don't look at the arguments you passed in. I'm not even returning a "User"; it's an "Anxiety", and the field types aren't exactly what a person would expect them to be from their name.
Obviously this is an absurd example, but the fact that this is all "correct from the standpoint of GraphQL" proves my point I think. GraphQL can do literally anything behind the scenes, as long as the input is in the format defined in the schema and the response is in the format defined in the schema.