Skip to content

GraphQl. Add a mutation for subscribe feature #27337

Closed
@atwixfirster

Description

@atwixfirster

Description (*)

There is a subscribe field on a standard Magento storefront:

27337

Currently, GraphQl does not have a mutation which allow to subscribe guest/customer into a newsletter subscription.

Expected behavior (*)

Benefits

Additional information

A proposed schema:

type Mutation {
    subscribeEmailToNewsletter(input: SubscribeInput): SubscribeOutput @resolver(class: "\\Vendor\\ModuleGraphQl\\Model\\Resolver\\SubscribeEmailToNewsletter") @doc(description:"Adds an email into a newsletter subscription")
}

input SubscribeInput {
    email: String! @doc(description: "Email")
}

type SubscribeOutput {
    success: Boolean! @doc(description: "Returns 'true' if an email has been added to newsletter successfully")
    message: String! @doc(description: "Returns a success or an error messages")
}

Example of usage:

mutation {
  subscribeEmailToNewsletter(
    input: {
      email: "[email protected]"
    }
  ) {
    success
    message
  }
}

Response:

{
  "data": {
    "subscribeEmailToNewsletter": {
      "success": true,
      "message": "Thank you for your subscription."
    }
  }
}

Metadata

Metadata

Labels

Component: GraphQLGraphQLComponent: NewsletterGraphQlFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPartner: AtwixPull Request is created by partner AtwixPriority: P2A defect with this priority could have functionality issues which are not to expectations.Project: GraphQLReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.Triage: DoneHas been reviewed and prioritized during Triage with Product Managersfeature request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions