Converted query with sort take HTTP error 400 Bad requesr
yoleoagain opened this issue ยท 8 comments
I don't think 400 HTTP errors can be related to this library. Are you sure that the query is correct? Your parameters looks strange to me, It is either a wrong query, or you are targeting the wrong endpoint for your graphQL client.
@ticruz38 Thx for your answer, i will be glad if you can help. How i can write a simple query sorted by date for example? This works in playground.
In the apollo-client
you have the right uri? to the good endpoint?
It's a bit difficult to help you out with this small information.
You mean that this is working;
$: query = GetItems({});
And this is not working (with a 400 error code);
$: query = GetItems({ variables: {sort: "created_at:DESC"}});
Is it a correct understanding?
$: query = GetItems({});
$: query = GetItems({});
- this code in both cases but, different gql syntax. May be it was something happend with my dev server, but now its 200OK with not sorted items.
-
Get items but not sorted
query GetItems { items(sort: "created_at:ASC") { id name description created_at } }
-
Get items too
query GetItems { items{ id name description created_at } }
I think I know what's wrong, and it may be a kind of flexibility that is not allowed by this plugin, I will need to try myself.
Can you try writing your query like this?
query GetItems($sort: String) {
items(sort: $sort) {
id
name
description
created_at
}
}
and use it like that
$: query = GetItems({sort: "created_at:ASC"});
$: query = GetItems({sort: "created_at:ASC"});
Thank you so much, it is works perfect, and your library is awesome and its very helps me. I'm new for backend and graphql and i use strapi headless cms which generate for me graphql schema and graphql-codegen-svelte-apollo. For me right syntax of calling query is
PS an thx to @jycouet