Skip to content

Conversation

@MathieuDutSik
Copy link
Contributor

Motivation

The MutationRoot implementation can be difficult to write down (but we have 4 examples doing that in the examples directory). Therefore, we have a trait GraphQLMutationRoot and a derive macro that allows implementing the MutationRoot more easily.

That macro represents the choices that we think are the right ones for smart contract writers. For example, we do not allow structs by design. It has recently emerged that field0 is not a favored design. Therefore, it makes full sense that the macro should not allow it.

Note that we do not force programmers to use the GraphQLMutationRoot. We also do not force them to use GraphQL. However, the GraphQLMutationRoot that we provide should represent the choices that we think are the right ones.

Proposal

Explicitly, forbid that check.

Test Plan

The CI.
Added a test for testing that this scenario is not allowed.

Release Plan

Safe to backport to the TestNet / DevNet.

Links

None.

@MathieuDutSik MathieuDutSik marked this pull request as ready for review September 24, 2025 18:44
@ma2bd
Copy link
Contributor

ma2bd commented Sep 25, 2025

We don't really need to disallow this. The macro works

@MathieuDutSik
Copy link
Contributor Author

We don't really need to disallow this. The macro works

That does not make sense to me.

We have two realistic scenarios:

  • Supporting as much as possible in the macro.
  • Providing support for the features that we recommend and only those.

The support for structs was proposed in a previous PR, but dismissed. Also, the field0 was an issue in recent works. So, why not prevent the use of anonymous variants?

Note also that the documentation is in dire contradiction with those stated best practices. In the documentation https://linera.dev/developers/backend/abi.html, the Operation is not a struct, not an enum, but a u64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants