8 April 2020
Composable Commerce
HTTP API
Enhancement
GraphQLMessages/Subscriptions

Subscriptions can now be queried, created, updated, and deleted using the GraphQL API.

  • [GraphQL API] Added the following types to the GraphQL schema: AzureServiceBusDestination, AzureServiceBusDestinationInput, ChangeSubscription, ChangeSubscriptionDestination, ChangeSubscriptionInput, CloudEventsSubscriptionsFormat, CloudEventsSubscriptionsFormatInput, Destination, DestinationInput, EventGridDestination, EventGridDestinationInput, GoogleCloudPubSubDestination, GoogleCloudPubSubDestinationInput, MessageSubscription, MessageSubscriptionInput, NotificationFormat, PlatformFormat, PlatformFormatInput, SNSDestination, SNSDestinationInput, SQSDestination, SQSDestinationInput, SetSubscriptionChanges, SetSubscriptionKey, SetSubscriptionMessages, Subscription, SubscriptionDraft, SubscriptionFormatInput, SubscriptionHealthStatus, SubscriptionQueryResult, SubscriptionUpdateAction.
  • [GraphQL API] Changed the Query type:
    • Added the subscription field to the Query type.
    • Added the subscriptions field to the Query type.
  • [GraphQL API] Changed the Mutation type:
    • Added the updateSubscription field to the Mutation type.
    • Added the deleteSubscription field to the Mutation type.
    • Added the createSubscription field to the Mutation type.

Introduced the following changes to the GraphQL schema (in SDL format):

extend type Query {
  subscription(
    "Queries with specified ID"
    id: String,

    "Queries with specified key"
    key: String): Subscription
  subscriptions(where: String, sort: [String!], limit: Int, offset: Int): SubscriptionQueryResult!
}

extend type Mutation {
  createSubscription(draft: SubscriptionDraft!): Subscription
  deleteSubscription(version: Long!,

    "Queries with specified ID"
    id: String,

    "Queries with specified key"
    key: String): Subscription
  updateSubscription(version: Long!, actions: [SubscriptionUpdateAction!]!,

    "Queries with specified ID"
    id: String,

    "Queries with specified key"
    key: String): Subscription
}

type AzureServiceBusDestination implements Destination {
  connectionString: String!
  type: String!
}

input AzureServiceBusDestinationInput {
  connectionString: String!
}

type ChangeSubscription {
  resourceTypeId: String!
}

input ChangeSubscriptionDestination {
  destination: DestinationInput!
}

input ChangeSubscriptionInput {
  resourceTypeId: String!
}

type CloudEventsSubscriptionsFormat implements NotificationFormat {
  type: String!
  cloudEventsVersion: String!
}

input CloudEventsSubscriptionsFormatInput {
  cloudEventsVersion: String!
}

interface Destination {
  type: String!
}

input DestinationInput {
  SQS: SQSDestinationInput
  SNS: SNSDestinationInput
  AzureServiceBus: AzureServiceBusDestinationInput
  EventGrid: EventGridDestinationInput
  GoogleCloudPubSub: GoogleCloudPubSubDestinationInput
}

type EventGridDestination implements Destination {
  uri: String!
  accessKey: String!
  type: String!
}

input EventGridDestinationInput {
  uri: String!
  accessKey: String!
}

type GoogleCloudPubSubDestination implements Destination {
  projectId: String!
  topic: String!
  type: String!
}

input GoogleCloudPubSubDestinationInput {
  projectId: String!
  topic: String!
}

type MessageSubscription {
  resourceTypeId: String!
  types: [String!]!
}

input MessageSubscriptionInput {
  resourceTypeId: String!
  types: [String!]
}

interface NotificationFormat {
  type: String!
}

type PlatformFormat implements NotificationFormat {
  type: String!
}

input PlatformFormatInput {
  dummy: String
}

type SNSDestination implements Destination {
  topicArn: String!
  accessKey: String!
  accessSecret: String!
  type: String!
}

input SNSDestinationInput {
  topicArn: String!
  accessKey: String!
  accessSecret: String!
}

type SQSDestination implements Destination {
  queueUrl: String!
  accessKey: String!
  accessSecret: String!
  region: String!
  type: String!
}

input SQSDestinationInput {
  queueUrl: String!
  accessKey: String!
  accessSecret: String!
  region: String!
}

input SetSubscriptionChanges {
  changes: [ChangeSubscriptionInput!]!
}

input SetSubscriptionKey {
  key: String
}

input SetSubscriptionMessages {
  messages: [MessageSubscriptionInput!]!
}

type Subscription implements Versioned {
  key: String
  destination: Destination!
  messages: [MessageSubscription!]!
  changes: [ChangeSubscription!]!
  format: NotificationFormat!
  status: SubscriptionHealthStatus!
  id: String!
  version: Long!
  createdAt: DateTime!
  lastModifiedAt: DateTime!
  createdBy: Initiator
  lastModifiedBy: Initiator
}

input SubscriptionDraft {
  key: String
  destination: DestinationInput!
  messages: [MessageSubscriptionInput!]
  changes: [ChangeSubscriptionInput!]
  format: SubscriptionFormatInput
}

input SubscriptionFormatInput {
  Platform: PlatformFormatInput
  CloudEvents: CloudEventsSubscriptionsFormatInput
}

enum SubscriptionHealthStatus {
  TemporaryError
  ConfigurationErrorDeliveryStopped
  ConfigurationError
  Healthy
}

type SubscriptionQueryResult {
  offset: Int!
  count: Int!
  total: Long!
  results: [Subscription!]!
}

input SubscriptionUpdateAction {
  changeDestination: ChangeSubscriptionDestination
  setChanges: SetSubscriptionChanges
  setKey: SetSubscriptionKey
  setMessages: SetSubscriptionMessages
}