Skip to content

Instantly share code, notes, and snippets.

@jicee13
Last active January 22, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jicee13/6600c2c62a514d103370a500cf189ddb to your computer and use it in GitHub Desktop.
Save jicee13/6600c2c62a514d103370a500cf189ddb to your computer and use it in GitHub Desktop.

Option 1

There is just one generic mutation that can handle all message creation. I am unsure how scalable this is. Main benefit I can think of is that we wouldn't need to adjust the graphql layer every time we added a new medium to send messages/notifications with. The more I think about this thought the more unreasonable it feels.

sendMessage(input: SendMessageInput!): Boolean

enum MessageType {
   EMAIL
   SMS
}

input SendMessageInput {
   sender: String
   recipient: String!
   subject: String
   htmlBody: string
   message: String
   type: MessageType
   templateId: ID
   organizationId: ID
}

Option 2

We make a separate mutation for every medium of message/notification sending. Main beneift here is that it is very clear what you are performing. I think as of right now I prefer this one. I like how explicit it is. Because in the end, we are going to make a lot of these messages/notifications event driven anyways (I think), so ideally the 3rd party user won't be using these mutations as often as they will be initially.

sendCustomEmail(input: SendCustomEmailInput!): Boolean
sendTemplateEmailInput(input: SendCustomEmailInput!): Boolean
sendCustomSMS(input: SendCustomSMSInput!): Boolean
sendTemplateSMS(input: SendTemplateSMSInput!): Boolean

input SendCustomEmailInput {
   sender: [String]!
   recipient: [String]!
   subject: String!
   htmlBody: String!
}

input sendTemplateEmailInput {
   templateId: ID!
   locale: Locale!
   organizationId: ID!
}

input SendCustomSMSInput {
   sender: String!
   recipient: [String]!
   messsage: String!
}

input sendTemplateSMSInput {
   templateId: ID!
   locale: Locale!
   organizationId: ID!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment