|
|
|
|
|
by valenterry
2007 days ago
|
|
> What stops a frontend developer writing an ad-hoc query? What stops them is that the "ad-hoc" query can only look like this: articlesWithComments($id) {
title
contents
comment {
author
text
}
}
That's all. Now the only way to change this query is to remove fields but there is no way to make anything more complex. The only way to do more is to repeat the query. I.e. literally: article1: articlesWithComment(1) {
title
contents
comment {
author
text
}
}
article2: articlesWithComment(2) {
title
contents
comment {
author
text
}
}
That will create two queries in the backend - that is the equivalent of just making two requests against the same REST route.It _is_ possible to allow a user to change the query like this: articlesWithComments($id) {
title
contents
comment {
author {
name,
age,
articles {
...
}
}
text
}
}
But that is totally optional - you don't have to give your users this power. |
|
What is "author" in that query and why can't the user do
in that query?And what you're basically saying is: let's create REST with extra steps for no particular reason. With extremely complex setups where author in one query has a different set of fields than in a different query etc.