tauri-plugin-graphql icon indicating copy to clipboard operation
tauri-plugin-graphql copied to clipboard

[question] How are things like tauri's `AppHandle` / `Window` being passed to async_graphql's Context

Open mikew opened this issue 1 year ago • 1 comments

Note: I would have made this a discussion but it seems like they're not enabled for this repo

I'm using this plugin (still works great btw), but am curious how something like ctx.data::<AppHandle>() is working? ctx is from async_graphql, and AppHandle is something from tauri.

I've been searching through the source code of this plugin, hoping to find an obvious place where you're saying "add tauri's app handle to async_graphql's context", but the only reference to it is in an example in a comment. So, it seems very magical at the moment.

mikew avatar Sep 14 '23 17:09 mikew

Of course, after posting this I noticed this, which probably answers my question:

https://github.com/JonasKruckenberg/tauri-plugin-graphql/blob/78b092deda2e8621a2291c480372d7b3e814b735/src/lib.rs#L246

Now I'm wondering why .inner is needed in subscriptions

https://github.com/JonasKruckenberg/tauri-plugin-graphql/blob/78b092deda2e8621a2291c480372d7b3e814b735/src/lib.rs#L258

mikew avatar Sep 14 '23 17:09 mikew