Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a type named Root in the schema #1049

Open
LennyLizowzskiy opened this issue Sep 28, 2024 · 1 comment
Open

Could not find a type named Root in the schema #1049

LennyLizowzskiy opened this issue Sep 28, 2024 · 1 comment

Comments

@LennyLizowzskiy
Copy link

I don't know if this is the right behavior or not, but the line graphql_type = "Root" errors with the "Could not find a type named Root in the schema" error

#[derive(cynic::QueryFragment, Debug)]
struct Anime {
    id: cynic::Id,
    name: String,
}

#[derive(cynic::QueryVariables)]
struct AnimeQueryVariables {
    search: String,
    page: u32,
    limit: u32,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(
    graphql_type = "Root",
    variables = "AnimeQueryVariables"
)]
struct AnimeQuery {
    #[arguments(search: $search, page: $page, limit: $limit, kind: "!music,!pv,!cm", order: "popularity")]
    animes: Vec<Anime>
}

If I understand it correctly, it should work because it was written like it in the docs:

#[derive(cynic::QueryFragment, Debug)]
struct Film {
    title: Option<String>,
    director: Option<String>,
}

#[derive(cynic::QueryVariables)]
struct FilmArguments {
    id: Option<cynic::Id>,
}

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Root", variables = "FilmArguments")]
struct FilmDirectorQuery {
    #[arguments(id: $id)]
    film: Option<Film>,
}
@obmarg
Copy link
Owner

obmarg commented Sep 30, 2024

What does your schema look like? Is the root query type named Root? It is in the star wars schema that is used by that example, but I suspect it's not in the schema you are using. It's commonly called Query but it can have any name.

If you change graphql_type = "Root" to name the correct type then it will probably work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants