[][src]Macro juniper_from_schema::graphql_schema

graphql_schema!() { /* proc-macro */ }

Write your GraphQL schema directly in your Rust code.

This is mostly useful for testing. Prefer using graphql_schema_from_file for larger schemas.

Example

This example is not tested
graphql_schema! {
    schema {
        query: Query
    }

    type Query {
        helloWorld: String! @juniper(ownership: "owned")
    }
}

pub struct Query;

impl QueryFields for Query {
    fn field_hello_world(
        &self,
        executor: &Executor<'_, Context>,
    ) -> FieldResult<String> {
        Ok("Hello, World!".to_string())
    }
}