-
Notifications
You must be signed in to change notification settings - Fork 79
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
As a library developer, I want to have candid_path rethought so that consumers of my library do not need to depend on ic_cdk directly #248
Comments
Let me try to better understand the problem here. The reason I was basically following serde's solution. Last time I checked, I think they have a |
The reason Basically I need to be able to tell CandidType where ic_cdk is, having it hard-coded is causing issues. Let me find the serde issue that really explains this |
And here is the issue: serde-rs/serde#1465 I believe the problem I had with serde is very similar to the problem I am now having with CandidType. You might need to use the serde solution within this project as well? |
I imagine a solution might look something like this: |
Thanks for the link. I was looking at the same issue two years ago, and there was no solution at that time. We have some higher priority tasks, so it will take some time before I can handle this issue. I would be happy to review a pull request from you if you want things to go faster. Another immediate workaround is to clone candid in your repo, and then you can do whatever change you want. |
Glad we're seeing the same thing now :) I might clone the repo and do a
pull request, seems the fastest way to solve my problem, though I also have
some priorities and can wait. We'll see, thanks for engaging on this issue
…On Sat, Jun 19, 2021, 12:40 PM Yan Chen ***@***.***> wrote:
Thanks for the link. I was looking at the same issue two years ago, and
there was no solution at that time. #[candid(crate="self")] looks like a
good solution.
We have some higher priority tasks, so it will take some time before I can
handle this issue. I would be happy to review a pull request from you if
you want things to go faster. Another immediate workaround is to clone
candid in your repo, and then you can do whatever change you want.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#248 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVNFD66BRDFMEXG6Z2SV6TTTTJCJANCNFSM466PO7PA>
.
|
I cloned the repo into Sudograph and have confirmed that changing the path manually works. Now I'll experiment a bit with |
Pull request: #249 I left some comments as I'm not sure on what conventions you have or what is best practice for unwrapping etc. I also went with |
This adds a #[candid_path("path_to_candid")] helper attribute to the candid derive macro, in response to this issue: #248
Is your feature request related to a problem? Please describe.
I am developing Sudograph, a procedural macro that is meant to be used within a Rust canister. Sudograph generates a GraphQL database, and reexports ic_cdk and other crates from cdk-rs. Right now, I have it designed so that the consumer of Sudograph only needs to depend on
sudograph
in their Cargo.toml for their canister. But as I've gotten into enabling cross-canister GraphQL resolvers, theCandidType
attribute macro has caused me problems. Because of the waycandid_path
is designed, see here: https://github.com/dfinity/candid/blob/master/rust/candid_derive/src/lib.rs#L36 I have to force the consumers of Sudograph to depend directly onic_cdk
, when otherwise they would not have to. I think the root of the problem is hardcoding this path::ic_cdk::export::candid
, especially the prefix::
.Describe the solution you'd like
Consider changing the hard-coded
candid_path
toic_cdk::export::candid
, or allow the developer to set the crate location manually in another macro. For example, serde had a very similar problem that was solved with the introduction of this#[serde(crate="self::serde")]
, allowing the developer to specify the location of the serde crate (or something like that, I'm still trying to wrap my head around Rust's packages, crates, and modules, but the serde solution works).Describe alternatives you've considered
I could always force the consumer of Sudograph to depend directly on
ic_cdk
, but it would be an extra inconvenience to them. Part of Sudograph's value proposition is being extremely simple, a sort of one-stop shop for developing on the IC using GraphQL. I have been messing with modules and crates to try and get this to work without needing changes to thecandid
libraries, but I'm not sure it's possible, and the fix on your end probably isn't too complicated.Additional context
I can give more context on the serde issue if desired, I would need to dig up the issue. Please understand that this is about the ergonomics and ease of use of libraries like Sudograph, right now the
CandidType
attribute macro is somewhat tightly coupled to a specific project structure and could be made more composable.The text was updated successfully, but these errors were encountered: