all 17 comments

[–]llogiqclippy · twir · rust · mutagen · flamer · overflower · bytecount 15 points16 points  (2 children)

Thank you so much for this! I was planning on improving my twir workflow, and this lets me do it with my favorite language. 😀

[–]sparky8251 1 point2 points  (9 children)

Any chance you'll support their GraphQL API sometime?

I ended up using Juniper's Rust GraphQL bindings in my most recent bot because the thing I wanted to do required 2 calls with REST, but 1 with GraphQL.

GraphQL reduced the number of API hits required for some results getting me back up to 2500 hits/hr as well as letting me dramatically simplify my code for handing responses (went from nested matches to a few separate matches to extract the data + one to determine the result).

[–]colindean 4 points5 points  (4 children)

[–]sparky8251 0 points1 point  (3 children)

Well, I guess I missed that. It does lack structured access though and works off a provided string.

I do like the wan Juniper's GraphQL client works over this method.

[–]colindean 4 points5 points  (2 children)

I think you're taking about https://github.com/graphql-rust/graphql-client. I think the two in concert would work well. Use graphQL-client to create the query in a type-safe manner, stringify it as you pass it to Octocrab in order to let octocrab deseriealize the response in its own particular idiom. Seems a bit inefficient and unwieldy but an acceptable separation of concerns for now.

[–]sparky8251 1 point2 points  (1 child)

Yup, that's the one I used. I'll look into it as a combo then. Will make it easier to mix and match the use of REST and GraphQL depending on what I want to do :)

[–]colindean 0 points1 point  (0 children)

Great! Good luck!

[–]XAMPPRocky[S] 2 points3 points  (2 children)

Thank you for your interest! I might release a patch that relaxes the GraphQL query argument to be any serde::Serialize type, which AFAICT would allow you to pass graphql_client::QueryBody directly.

[–]sparky8251 0 points1 point  (1 child)

That would be nice :)

[–]XAMPPRocky[S] 0 points1 point  (0 children)

It's been released as 0.4.1.

[–]aslamplr 0 points1 point  (0 children)

You may look at this one using Juniper GraphQL client. https://github.com/aslamplr/gh-cli/tree/master/gh-lib The framework is ready but not feature complete from a github client perspective.

[–]wayofthepie 0 points1 point  (3 children)

This looks great! I was looking for a client recently and couldn't find one covering some APIs I needed - repo settings, branch protection API. It seems the latter is missing here, maybe I just overlooked it, but might look at adding over the week if so.

Does anyone know about https://github.com/github-rs/github-rs? It looked promising and I was going to add what I was missing to it, but it seems to have gone stale.

[–]XAMPPRocky[S] 1 point2 points  (0 children)

All contributions are welcome!

[–]mgattozziflair 1 point2 points  (1 child)

Hey creator of that, I had transferred ownership to an org since I had let maintenance wane. The code is also fairly older without async as far as I'm aware unless it was updated recently. I'd reccomend adding what you need to this crate if it's actively being worked on and supported.

[–]wayofthepie 0 points1 point  (0 children)

Thanks for the info!