Question about async graphql Object and Input Object

Can someone confirm my understanding that it is IMPOSSIBLE to have a Rust struct be both an Object (types that can be queried and represented as JSON objects in the response) and an InputObject (types that can be used to pass arguments to GraphQL queries and mutations but cannot be queried themselves.)?

For reference, I want to pass in a Vec of BookRecord within a Mutation Resolver but also return a Vec of
BookRecord but the Rust compiler panics because: 'Register BookRecord as InputObject, but it is already registered as Object.

If the above set up is impossible, what is next step to try and make my above approach work?

I'm pretty sure the Rust compiler doesn't panic, but your progam does. However, it's hard/impossible to tell what your problem is without a concrete code sample. Please provide a real, minimal, self-contained example that reproduces your problem.

Apologies, see code below!

As you can see, I annotate the BookRecord struct with both the InputObject and Object macro.

#[derive(Clone, Debug, Serialize, Deserialize, InputObject)]
pub struct BookRecord {
    pub _id: ID,
    pub data: Book,

impl BookRecord {
    async fn _id(&self) -> &str {

    async fn name(&self) -> &str {

    async fn author(&self) -> &str {

Solved. It seems that this is an inherent design limitation of the async graphql crate:

I believe the fix to my problem will require some degree of duplication: A BookRecordInput struct that is fed into the resolver and a BookRecord struct that is the actual return value.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.