Skip to content

Create Contact Us

About

The createContactUs mutation allows customers to submit a contact form enquiry to the store. Use this mutation to:

  • Submit customer enquiries from the storefront contact page
  • Send support requests to the store team
  • Allow guests (unauthenticated users) to reach out without an account
  • Collect customer contact details alongside their message
  • Track form submissions using clientMutationId
  • Integrate contact forms in custom storefronts or mobile apps

This mutation does not require authentication — it is available to all visitors.

Arguments

ArgumentTypeRequiredDescription
inputcreateContactUsInput!✅ YesInput object containing all contact form fields.

Input Fields (createContactUsInput)

FieldTypeRequiredDescription
nameString!✅ YesFull name of the person submitting the enquiry.
emailString!✅ YesEmail address to reply to. Must be a valid email format.
contactString!✅ YesContact phone number (e.g. +1234567890).
messageString!✅ YesThe enquiry or message body.
clientMutationIdString❌ NoOptional client-side identifier for tracking the mutation request.

Possible Returns

FieldTypeDescription
contactUs.successBoolean!true if the contact form was submitted successfully.
contactUs.messageString!Human-readable confirmation or error message returned by the server.
clientMutationIdStringEchoed back from the input if provided; useful for client-side request tracking.

Use Cases

1. Storefront Contact Page

Trigger this mutation when a customer submits the contact form on /contact-us, then display the response message as a success or error notification.

2. Guest Enquiries

Since no authentication is required, use this mutation for anonymous visitors who want to reach out without creating an account.

3. Mobile App Contact Form

Integrate into a React Native or Flutter app to allow users to send support messages directly from within the app.

4. Track Submissions Client-Side

Pass a unique clientMutationId (e.g. a UUID) to correlate the GraphQL response with the originating form submission in your frontend state.

5. Headless Storefronts

Use in any headless commerce setup to power the contact form without relying on Bagisto's default frontend templates.

Best Practices

  1. Validate on the client first — Check email format and non-empty fields before calling the mutation to reduce unnecessary API calls
  2. Always check success — Do not rely solely on the absence of errors; always read contactUs.success to confirm submission
  3. Display message to the user — Show the server's response message as feedback so users know whether their enquiry was received
  4. Prevent duplicate submissions — Disable the submit button after a successful response to avoid repeated submissions
  5. Rate limit on the server — Ensure your Bagisto instance has rate limiting configured to protect this endpoint from abuse
  6. Use clientMutationId for tracking — Pass a unique ID per submission if you need to correlate requests in analytics or error monitoring

Released under the MIT License.