Mex feature wraps WhatsApp’s Meta Exchange (MEX) GraphQL API. Operations are persisted: you reference each query or mutation by a (name, id) pair pulled from a generated operation module, and pass its typed Variables. WhatsApp Web bundle updates rotate the numeric id, so the human-readable name keeps diagnostics stable across releases.
Access
Building a request
Each persisted operation lives in its own module underwacore::iq::mex_operations. Every module exposes:
NAME— the operation name (e.g."WAWebJoinNewsletterMutation").DOC_ID— the current persisted document ID.OPERATION_KIND—"query"or"mutation".Variables— a typed struct matching the operation’s input shape.Response— a typed struct matching the operation’s output shape.
MexRequest with MexRequest::new using those constants and a Variables value:
Methods
query
Execute a GraphQL query.mutate
Execute a GraphQL mutation.serde_json:
Types
MexDoc
A persisted-query descriptor. Re-exported fromwacore::iq::mex.
MexRequest
A persisted-query descriptor plus its typed variables.V is the variables type — usually the generated Variables struct for an operation, but any Serialize value works.
new
Pair an operation’sNAME and DOC_ID with its variables.
MexResponse
Response from a GraphQL operation.has_data()—trueif the response contains data.has_errors()—trueif the response contains errors.fatal_error()— the first fatal error (any error with anerror_code), if any.
MexGraphQLError
error_code()— the numeric error code, if present.is_summary()—truewhen the error is marked as a summary.has_error_code()—truewhen an error code is set.
MexGraphQLError is re-exported from the crate root as whatsapp_rust::MexGraphQLError, alongside MexError, MexErrorExtensions, MexRequest, and MexResponse.MexErrorExtensions
Error handling
query and mutate automatically convert any fatal GraphQL error (any error with an error_code) into MexError::ExtensionError so you can match on it without inspecting response.errors yourself.
Response handling
Check for data
Handle non-fatal errors
Errors without anerror_code are non-fatal and surface in response.errors alongside any partial data.
Decode the typed response
Generated operation modules also expose aResponse struct that mirrors the GraphQL schema. Decode it from response.data with serde_json:
The persisted
DOC_ID for each operation is regenerated from the latest WhatsApp Web bundle. Pin to a specific crate version if you need a stable wire format.