Crate shopify_function

Source
Expand description

Crate to write Shopify Functions in Rust.

This crate provides some convenience when building Shopify Functions using Rust. The crate takes care of generating the required Rust structs to handle the data types being passed between Shopify and the Function. The crate also takes care of deserializing the input data and serializing the output data.

use shopify_function::prelude::*

#[typegen("./schema.graphql")]
mod schema {
    #[query("./input.graphql")]
    pub mod input {}
}

#[shopify_function]
fn run(input: schema::input::Input) -> Result<schema::FunctionRunResult> {
    /* ... */
}

Re-exports§

pub use shopify_function_wasm_api as wasm_api;

Modules§

prelude
scalars

Functions§

run_function_with_input
Runs the given function f with the invocation payload, returning the deserialized output. This function is provided as a helper when writing tests.

Type Aliases§

Result

Attribute Macros§

shopify_function
Generates code for a Function. This will define a wrapper function that is exported to Wasm. The wrapper handles deserializing the input and serializing the output.
typegen
Generates Rust types from GraphQL schema definitions and queries.

Derive Macros§

Deserialize
Derives the Deserialize trait for structs to deserialize values from shopify_function_wasm_api::Value.