-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add extern_enums
and skip codegen for large enums
#56
Conversation
extern_enums
, apply it to large enumsextern_enums
and skip codegen for large enums
a9792ac
to
3e066d9
Compare
- `query_path`: A path to a GraphQL query, whose result will be used | ||
as the input for the function invocation. The query MUST be named "Input". | ||
- `schema_path`: A path to Shopify's GraphQL schema definition. Use the CLI | ||
to download a fresh copy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now the same copy as the macro's Rustdoc.
The `generate_types` macro didn't use `parse_macro_input!` to parse its arguments, unlike other macros. This unifies arg parsing across macros, making it easier to add a field to all macros.
9ed7308
to
f0a8c2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Love the macro parsing refactor 😃
What's the behaviour for an enum that doesn't exist?
The `extern_enums` arg is forwarded to the `graphql-client` crate, which will use it as the type for the enum instead of generating code for it. By default, the 3 large enums from Function APIs are passed as `extern_enums`: LanguageCode, CountryCode, CurrencyCode. Users can override that by sending `extern_enums` explicitly.
c563e56
to
3bf99bb
Compare
The behaviour of the underlying crate, which is:
|
Codegen for large enums bloat the Wasm binary size on top of producing not-very-efficient deserializing code.
This PR adds an
extern_enums
arg to the relevant macros. Theextern_enums
arg is forwarded to thegraphql-client
crate, which will skip codegen for those enums. The type is expected to already be defined, with e.g.type CountryCode = String;
.By default, the 3 large enums from Function APIs are defined as Strings and passed as
extern_enums
: LanguageCode, CountryCode, CurrencyCode. Users can override that by sendingextern_enums
explicitly.Decisions:
extern_enums = ["Foo", "Bar"]
instead of graphql-client'sextern_enums("Foo", "Bar")
. I thought this was more aligned with the other attributes.DiscountApplicationStrategy
), and only problematic for large enums.Note: this PR is best reviewed commit-by-commit.