"A single calculated tax for a cart, order group, cart item, or order item"
type TaxRate {
  "Tax rate ID"
  _id: ID!

  "An optional country code to limit where this tax is applied, in conjunction with `sourcing` field"
  country: String

  "An optional postal code to limit where this tax is applied, in conjunction with `sourcing` field"
  postal: String

  "The tax rate. For example, 0.05 for a 5% sales tax."
  rate: Float!

  "An optional region (e.g., state) to limit where this tax is applied, in conjunction with `sourcing` field"
  region: String

  "The shop to which this TaxRate belongs"
  shop: Shop!

  "Whether the `country`, `postal`, and `region` filters apply to the origin address or the destination address"
  sourcing: TaxSource!

  "An optional tax code, to apply this tax rate to only products that have this tax code"
  taxCode: String
}

"The input for creating a tax rate"
input CreateTaxRateInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "An optional country code to limit where this tax is applied based on destination address"
  country: String

  "An optional postal code to limit where this tax is applied based on destination address"
  postal: String

  "The tax rate. For example, 0.05 for a 5% sales tax."
  rate: Float!

  "An optional region (e.g., state) to limit where this tax is applied based on destination address"
  region: String

  "Shop ID"
  shopId: ID!

  "Whether the `country`, `postal`, and `region` filters apply to the origin address or the destination address"
  sourcing: TaxSource = destination

  "An optional tax code, to apply this tax rate to only products that have this tax code"
  taxCode: String
}

"The response from the `createTaxRate` mutation"
type CreateTaxRatePayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The created tax rate"
  taxRate: TaxRate!
}

"""
The input for updating a tax rate. Note that missing values will cause the field to be cleared, so
send all optional fields with every request unless they aren't currently set or you intend to clear them.
"""
input UpdateTaxRateInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "An optional country code to limit where this tax is applied based on destination address"
  country: String

  "An optional postal code to limit where this tax is applied based on destination address"
  postal: String

  "The tax rate. For example, 0.05 for a 5% sales tax."
  rate: Float!

  "An optional region (e.g., state) to limit where this tax is applied based on destination address"
  region: String

  "Shop ID"
  shopId: ID!

  "Whether the `country`, `postal`, and `region` filters apply to the origin address or the destination address"
  sourcing: TaxSource

  "An optional tax code, to apply this tax rate to only products that have this tax code"
  taxCode: String

  "ID of the tax rate you want to update"
  taxRateId: ID!
}

"The response from the `updateTaxRate` mutation"
type UpdateTaxRatePayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated tax rate"
  taxRate: TaxRate!
}

"Describes the input for removing a tax rate"
input DeleteTaxRateInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "Shop ID"
  shopId: ID!

  "The tax rate ID"
  taxRateId: ID!
}

"The response from the `deleteTaxRate` mutation"
type DeleteTaxRatePayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The deleted tax rate"
  taxRate: TaxRate!
}

extend type Mutation {
  "Create a new tax rate"
  createTaxRate(
    "Mutation input"
    input: CreateTaxRateInput!
  ): CreateTaxRatePayload

  "Update a tax rate"
  updateTaxRate(
    "Mutation input"
    input: UpdateTaxRateInput!
  ): UpdateTaxRatePayload

  "Delete a tax rate"
  deleteTaxRate(
    "Mutation input"
    input: DeleteTaxRateInput!
  ): DeleteTaxRatePayload
}

"A connection edge in which each node is a `TaxRate` object"
type TaxRateEdge {
  "The cursor that represents this node in the paginated results"
  cursor: ConnectionCursor!

  "The tax rate"
  node: TaxRate
}

"""
Wraps a list of TaxRate`s, providing pagination cursors and information.

For information about what Relay-compatible connections are and how to use them, see the following articles:
- [Relay Connection Documentation](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections)
- [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm)
- [Using Relay-style Connections With Apollo Client](https://www.apollographql.com/docs/react/recipes/pagination.html)
"""
type TaxRateConnection {
  "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each"
  edges: [TaxRateEdge]

  """
  You can request the `nodes` directly to avoid the extra wrapping that `NodeEdge` has,
  if you know you will not need to paginate the results.
  """
  nodes: [TaxRate]

  "Information to help a client request the next or previous page"
  pageInfo: PageInfo!

  "The total number of nodes that match your query"
  totalCount: Int!
}

extend type Query {
  "Gets tax rates"
  taxRates(
    "Provide a shp ID from which you want to get tax rates"
    shopId: ID!

    "Return only results that come after this cursor. Use this with `first` to specify the number of results to return."
    after: ConnectionCursor,

    "Return only results that come before this cursor. Use this with `last` to specify the number of results to return."
    before: ConnectionCursor,

    "Return at most this many results. This parameter may be used with either `after` or `offset` parameters."
    first: ConnectionLimitInt,

    "Return at most this many results. This parameter may be used with the `before` parameter."
    last: ConnectionLimitInt,

    "Return only results that come after the Nth result. This parameter may be used with the `first` parameter."
    offset: Int
  ): TaxRateConnection
}
