graphql_client
is giving me an array of errors and i'd like to convert them to FieldError
s and pass them back
an error response from juniper::FieldError::new
looks like this:
{
"errors": [
{
"message": "error 1",
"locations": [{ "line": 2, "column": 4 }]
}
]
}
my question is, is it possible to create something like this?:
{
"errors": [
{
"message": "error 1",
"locations": [{ "line": 2, "column": 4 }]
},
{
"message": "error 2",
"locations": [{ "line": 2, "column": 4 }]
}
]
}
Hey,
I'd like to combine Juniper and Diesel (using postgres) in an efficient (few and optimized queries) and a minimal boilerplate way:
I have let's say a model User and a model Post, where a User has a one to many relationship to Post.
Like this:
struct Post {
id: String,
title: String,
content: String,
published_at: DateTime<Utc>,
}
struct User {
id: String,
name: String,
posts: Vec<Post>,
}
(Note that posts
it is not an Option, this is not necessarily a requirement, but would be great to have support for this as well)
Is there a way to only query the User without querying the posts from the database with a single query like this:
{
allUsers {
id
name
}
}
and if posts
is specified
{
allUsers {
id
name
posts {
title
published_at
}
}
to extend this to two queries (one for the users, and one for posts). What would be even more optimal: One query, with e.g. json_agg
of postgres for the posts to save 'joined overhead'.
I'm not sure how to achieve this. It would be great to get the queried fields from the request and generate a query for the database based on the queried fields.
Hi, I am now going through the rocket/juniper docs+book+examples and am getting an error on one of my route handlers with the schema param.
type Schema = RootNode<'static, Query, Mutation>;
#[post("/graphql", data = "<request>")]
fn graphql_handler(
context: DbConn,
request: juniper_rocket::GraphQLRequest,
schema: Schema,
) -> juniper_rocket::GraphQLResponse {
request.execute(&schema, &context)
}
The error I'm getting is:
the trait `rocket::request::FromRequest<'_, '_>` is not implemented for `juniper::schema::model::RootNode<'static, Query, Mutation>`
Am I required to implement this trait for the RootNode? I don't see that in any of the examples I've looked at so far. (I'm likely missing something obvious).
State
feature of rocket