Skip to content

0.1.1

Latest
Compare
Choose a tag to compare
@Tak-Iwamoto Tak-Iwamoto released this 12 Feb 07:14
· 4 commits to main since this release
87a31f5

https://github.com/Tak-Iwamoto/rusty-gql/pull/18/files

Improve Code Generate

  • support incremental file update
    We can generate Rust files incrementally.

Initial

schema.graphql

type Todo {
  title: String!
  content: String
  done: Boolean!
}

src/graphql/resolver/todo.rs

pub struct Todo {
    pub title: String,
    pub content: Option<String>,
    pub done: bool,
}
#[GqlType]
impl Todo {
    pub async fn title(&self, ctx: &Context<'_>) -> String {
        self.title.clone()
    }
    pub async fn content(&self, ctx: &Context<'_>) -> Option<String> {
        self.content.clone()
    }
    pub async fn done(&self, ctx: &Context<'_>) -> bool {
        self.done
    }
}

Update GraphQL schemas and Run rusty-gql g

schema.graphql

type Todo {
  title: String!
  content: String
  done: Boolean!
  user: User!
}

type User {
  name: String!
}

src/graphql/resolver/todo.rs

pub struct Todo {
    pub title: String,
    pub content: Option<String>,
    pub done: bool,
}
#[GqlType]
impl Todo {
    pub async fn title(&self, ctx: &Context<'_>) -> String {
        self.title.clone()
    }
    pub async fn content(&self, ctx: &Context<'_>) -> Option<String> {
        self.content.clone()
    }
    pub async fn done(&self, ctx: &Context<'_>) -> bool {
        self.done
    }
    // We can add incrementally
    pub async fn user(&self, ctx: &Context<'_>) -> User {
        todo!()
    }
}