# An object with an ID field to support global identification, in accordance with the
# Relay specification.
# This interface is used by the node
# and nodes queries.
interface Node {
    # A globally-unique identifier.
    id: ID!
}

# The subject line of a comment event.
interface CommentEventSubject {
    # A globally-unique identifier.
    id: ID!

    # Whether the timeline subject has a timeline comment. If true, then a timeline comment exists.
    hasTimelineComment: Boolean!
}

# Represents an object that has a list of events.
interface HasEvents {
    # The paginated list of events associated with the host subject.
    events(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
        sortKey: EventSortKeys = ID
        query: String
    ): EventConnection!
}

# Events chronicle resource activities such as the creation of an article, the fulfillment of an order, or the
# addition of a product.
interface Event {
    # The name of the app that created the event.
    appTitle: String

    # Whether the event was created by an app.
    attributeToApp: Boolean!

    # Whether the event was caused by an admin user.
    attributeToUser: Boolean!

    # The date and time when the event was created.
    createdAt: DateTime!

    # Whether the event is critical.
    criticalAlert: Boolean!

    # A globally-unique identifier.
    id: ID!

    # Human readable text that describes the event.
    message: FormattedString!
}

# Represents information about the metafields associated to the specified resource.
interface HasMetafields {
    # Returns a metafield by namespace and key that belongs to the resource.
    metafield(namespace: String!key: String!): Metafield

    # List of metafields that belong to the resource.
    metafields(
        namespace: String
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): MetafieldConnection!

    # Returns a private metafield by namespace and key that belongs to the resource.
    privateMetafield(namespace: String!key: String!): PrivateMetafield

    # List of private metafields that belong to the resource.
    privateMetafields(
        namespace: String
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): PrivateMetafieldConnection!
}

# Interoperability metadata for types that directly correspond to a REST Admin API resource.
# For example, on the Product type, LegacyInteroperability returns metadata for the corresponding Product object in the REST Admin API.
interface LegacyInteroperability {
    # The ID of the corresponding resource in the REST Admin API.
    legacyResourceId: UnsignedInt64!
}

# Localization extensions associated with the specified resource. For example, the tax id for government invoice.
interface HasLocalizationExtensions {
    # List of localization extensions for the resource.
    localizationExtensions(
        countryCodes: [CountryCode!]
        purposes: [LocalizationExtensionPurpose!]
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): LocalizationExtensionConnection!
}

# Resources that metafield definitions can be applied to.
interface HasMetafieldDefinitions {
    # List of metafield definitions.
    metafieldDefinitions(
        namespace: String
        pinnedStatus: MetafieldDefinitionPinnedStatus = ANY
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
        sortKey: MetafieldDefinitionSortKeys = ID
        query: String
    ): MetafieldDefinitionConnection!
}

# A default cursor that you can use in queries to paginate your results. Each edge in a connection can
# return a cursor, which is a reference to the edge's position in the connection. You can use an edge's cursor as
# the starting point to retrieve the nodes before or after it in a connection.
#
# To learn more about using cursor-based pagination, refer to
# Paginating results with GraphQL.
interface Navigable {
    # A default cursor that returns the single next record, sorted ascending by ID.
    defaultCursor: String!
}

# Discount applications capture the intentions of a discount source at
# the time of application on an order's line items or shipping lines.
#
# Discount applications don't represent the actual final amount discounted on a line (line item or shipping line). The actual amount discounted on a line is represented by the DiscountAllocation object.
interface DiscountApplication {
    # The method by which the discount's value is applied to its entitled items.
    allocationMethod: DiscountApplicationAllocationMethod!

    # An ordered index that can be used to identify the discount application and indicate the precedence
    # of the discount application for calculations.
    index: Int!

    # How the discount amount is distributed on the discounted lines.
    targetSelection: DiscountApplicationTargetSelection!

    # Whether the discount is applied on line items or shipping lines.
    targetType: DiscountApplicationTargetType!

    # The value of the discount application.
    value: PricingValue!
}

# Published translations associated with the resource.
interface HasPublishedTranslations {
    # The translations associated with the resource.
    translations(locale: String!marketId: ID): [PublishedTranslation!]!
}

# Represents an error in the input of a mutation.
interface DisplayableError {
    # The path to the input field that caused the error.
    field: [String!]

    # The error message.
    message: String!
}

# Services and features purchased once by the store.
interface AppPurchase {
    # The date and time when the app purchase occurred.
    createdAt: DateTime!

    # The name of the app purchase.
    name: String!

    # The amount to be charged to the store for the app purchase.
    price: MoneyV2!

    # The status of the app purchase.
    status: AppPurchaseStatus!

    # Whether the app purchase is a test transaction.
    test: Boolean!
}

# Represents a resource that can be published to a channel.
# A publishable resource can be either a Product or Collection.
interface Publishable {
    # The number of publications a resource is published to without feedback errors.
    availablePublicationCount: Int!

    # The number of publications a resource is published on.
    publicationCount(onlyPublished: Boolean = true): Int!

    # Check to see whether the resource is published to the calling app's publication.
    publishedOnCurrentPublication: Boolean!

    # Check to see whether the resource is published to a given publication.
    publishedOnPublication(publicationId: ID!): Boolean!

    # The list of resources that are published to a publication.
    resourcePublications(
        onlyPublished: Boolean = true
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): ResourcePublicationConnection!

    # The list of resources that are either published or staged to be published to a publication.
    resourcePublicationsV2(
        onlyPublished: Boolean = true
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): ResourcePublicationV2Connection!

    # The list of publications that the resource is not published to.
    unpublishedPublications(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): PublicationConnection!
}

# Represents a session preceding an order, often used for building a timeline of events leading to an order.
interface CustomerMoment {
    # The date and time when the customer's session occurred.
    occurredAt: DateTime!
}

# Represents subscription contract common fields.
interface SubscriptionContractBase {
    # The subscription app that the subscription contract is registered to.
    app: App

    # The URL of the subscription contract page on the subscription app.
    appAdminUrl: URL

    # The currency that's used for the subscription contract.
    currencyCode: CurrencyCode!

    # A list of the custom attributes to be added to the generated orders.
    customAttributes: [Attribute!]!

    # The customer to whom the subscription contract belongs.
    customer: Customer

    # The customer payment method that's used for the subscription contract.
    customerPaymentMethod(showRevoked: Boolean = false): CustomerPaymentMethod

    # The delivery method for each billing of the subscription contract.
    deliveryMethod: SubscriptionDeliveryMethod

    # The delivery price for each billing of the subscription contract.
    deliveryPrice: MoneyV2!

    # The list of subscription discounts associated with the subscription contract.
    discounts(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): SubscriptionManualDiscountConnection!

    # The number of lines associated with the subscription contract.
    lineCount: Int!

    # The list of subscription lines associated with the subscription contract.
    lines(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): SubscriptionLineConnection!

    # The note field that will be applied to the generated orders.
    note: String

    # A list of the subscription contract's orders.
    orders(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): OrderConnection!

    # The date and time when the subscription contract was updated.
    updatedAt: DateTime!
}

# A contract between a merchant and a customer to do business.
# Shopify creates a sales agreement whenever an order is placed, edited, or refunded.
# A sales agreement has one or more sales records, which provide itemized details about the initial agreement or subsequent changes made to the order.
# For example, when a customer places an order, Shopify creates the order, generates a sales agreement, and records a sale for each line item purchased in the order.
# A sale record is specific to a type of order line. Order lines can represent different things such as a purchased product, a tip added by a customer, shipping costs collected at checkout, and more.
interface SalesAgreement {
    # The application that created the agreement.
    app: App

    # The date and time at which the agreement occured.
    happenedAt: DateTime!

    # The unique identifier for the agreement.
    id: ID!

    # The reason the agremeent was created.
    reason: OrderActionType!

    # The sales associated with the agreement.
    sales(
        first: Int
        after: String
        last: Int
        before: String
        reverse: Boolean = false
    ): SaleConnection!

    # The staff member associated with the agreement.
    user: StaffMember
}

# An individual sale record associated with a sales agreement.
# Every money value in an order's sales data is represented in the currency's smallest unit.
# When amounts are divided across multiple line items, such as taxes or order discounts, the amounts might not divide evenly across all of the line items on the order.
# To address this, the remaining currency units that couldn't be divided evenly are allocated one at a time, starting with the first line item, until they are all accounted for.
# In aggregate, the values sum up correctly. In isolation, one line item might have a different tax or discount amount than another line item of the same price, before taxes and discounts.
# This is because the amount could not be divided evenly across the items. The allocation of currency units across line items is immutable.
# After they are allocated, currency units are never reallocated or redistributed among the line items.
interface Sale {
    # The type of order action that the sale represents.
    actionType: SaleActionType!

    # The unique identifier for the sale.
    id: ID!

    # The line type assocated with the sale.
    lineType: SaleLineType!

    # The number of units either ordered or intended to be returned.
    quantity: Int

    # All individual taxes associated with the sale.
    taxes: [SaleTax!]!

    # The total sale amount after taxes and discounts.
    totalAmount: MoneyBag!

    # The total discounts allocated to the sale after taxes.
    totalDiscountAmountAfterTaxes: MoneyBag!

    # The total discounts allocated to the sale before taxes.
    totalDiscountAmountBeforeTaxes: MoneyBag!

    # The total amount of taxes for the sale.
    totalTaxAmount: MoneyBag!
}

# A geographic region which comprises a market.
interface MarketRegion {
    # A globally-unique identifier.
    id: ID!

    # The name of the region.
    name: String!
}

# Online Store preview URL of the object.
interface OnlineStorePreviewable {
    # The online store preview URL.
    onlineStorePreviewUrl: URL
}

# Represents a media interface.
interface Media {
    # A word or phrase to share the nature or contents of a media.
    alt: String

    # The media content type.
    mediaContentType: MediaContentType!

    # Any errors which have occurred on the media.
    mediaErrors: [MediaError!]!

    # The warnings attached to the media.
    mediaWarnings: [MediaWarning!]!

    # The preview image for the media.
    preview: MediaPreviewImage

    # Current status of the media.
    status: MediaStatus!
}

# A file interface.
interface File {
    # A word or phrase to describe the contents or the function of a file.
    alt: String

    # The date and time (ISO 8601 format) when the file was created.
    createdAt: DateTime!

    # Any errors that have occurred on the file.
    fileErrors: [FileError!]!

    # The status of the file.
    fileStatus: FileStatus!

    # The preview image for the media.
    preview: MediaPreviewImage
}

# Represents selling plan pricing policy common fields.
interface SellingPlanPricingPolicyBase {
    # The price adjustment type.
    adjustmentType: SellingPlanPricingPolicyAdjustmentType!

    # The price adjustment value.
    adjustmentValue: SellingPlanPricingPolicyAdjustmentValue!
}
