Skip to content

How to handle cyclic dependencies? #1397

Answered by Miaxos
immerhart asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

In fact we do not build a really recursive struct, it's more about functions. Here is an example.

With something like this:

struct Foo;
struct Bar;

#[Object]
impl Foo {
    async fn bar(&self) -> Bar {
        Bar
    }
}

#[Object]
impl Bar {
    async fn foo(&self) -> Foo {
        Foo
    }

    async fn something(&self) -> bool {
        true
    }
}

#[Object]
impl Query {
    async fn foo(&self) -> Foo {
        Foo
    }
}

struct Query;

It would allow you to do query like this:

query test4 {
  foo {
    bar {
      foo {
        bar {
          foo {
            bar {
              something
            }
          }
        }
      }
    }
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@immerhart
Comment options

Answer selected by immerhart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants