"""
An address validation rule specifies which validation services should run for
which countries in each shop.
"""
type AddressValidationRule implements Node {
  "The rule ID"
  _id: ID!

  "Country codes for which this service is enabled"
  countryCodes: [String]

  "The date and time at which this rule was created"
  createdAt: DateTime!

  """
  The name of one of the installed validation services. Use `addressValidationServices`
  query to get a list with more details about all installed services.
  """
  serviceName: String!

  "ID of the shop to which this rule applies"
  shopId: ID!

  "The date and time at which this rule was last updated"
  updatedAt: DateTime!
}

"Input for the `createAddressValidationRule` mutation"
input CreateAddressValidationRuleInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "Country codes for which this service is enabled. `null` means all, while an empty array means none."
  countryCodes: [String]

  """
  The name of one of the installed validation services. Use `addressValidationServices`
  query to get a list, and then use the `name` field value from one of them.
  """
  serviceName: String!

  "ID of the shop to which this rule applies"
  shopId: ID!
}

"Input for the `deleteAddressValidationRule` mutation"
input DeleteAddressValidationRuleInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "ID of the rule you want to delete"
  ruleId: ID!

  "Shop ID of the rule you want to delete"
  shopId: ID!
}

"Input for the `updateAddressValidationRule` mutation"
input UpdateAddressValidationRuleInput {
  "An optional string identifying the mutation call, which will be returned in the response payload"
  clientMutationId: String

  "Country codes for which this service is enabled. `null` means all, while an empty array means none."
  countryCodes: [String]

  "ID of the rule you want to update"
  ruleId: ID!

  """
  The name of one of the installed validation services. Use `addressValidationServices`
  query to get a list, and then use the `name` field value from one of them.
  """
  serviceName: String!

  "Shop ID of the rule you want to update. This is not something you can modify."
  shopId: ID!
}

"Payload for the `createAddressValidationRule` mutation"
type CreateAddressValidationRulePayload {
  "Created address validation rule"
  addressValidationRule: AddressValidationRule!

  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String
}

"Payload for the `deleteAddressValidationRule` mutation"
type DeleteAddressValidationRulePayload {
  "Deleted address validation rule"
  addressValidationRule: AddressValidationRule!

  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String
}

"Payload for the `updateAddressValidationRule` mutation"
type UpdateAddressValidationRulePayload {
  "Updated address validation rule"
  addressValidationRule: AddressValidationRule!

  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String
}

extend type Mutation {
  "Create an address validation rule"
  createAddressValidationRule(
    "Mutation input"
    input: CreateAddressValidationRuleInput!
  ): CreateAddressValidationRulePayload!

  "Delete an address validation rule"
  deleteAddressValidationRule(
    "Mutation input"
    input: DeleteAddressValidationRuleInput!
  ): DeleteAddressValidationRulePayload!

  "Update an address validation rule"
  updateAddressValidationRule(
    "Mutation input"
    input: UpdateAddressValidationRuleInput!
  ): UpdateAddressValidationRulePayload!
}

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

  "The address validation rule"
  node: AddressValidationRule
}

"""
Wraps a list of `AddressValidationRules`, 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 AddressValidationRuleConnection {
  "The list of nodes that match the query, wrapped in an edge to provide a cursor string for each"
  edges: [AddressValidationRuleEdge]

  """
  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: [AddressValidationRule]

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

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

"The fields by which you are allowed to sort any query that returns an `AddressValidationRuleConnection`"
enum AddressValidationRuleSortByField {
  "AddressValidationRule ID"
  _id

  "Date and time at which the rule was created"
  createdAt

  "Service name"
  serviceName

  "Date and time at which the rule was last updated"
  updatedAt
}

extend type Query {
  "Returns a list of defined address validation rules for a shop"
  addressValidationRules(
    "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,

    "An optional list of service names, to get only rules that specify one of these services"
    serviceNames: [String],

    "ID of the shop for which to get defined address validation rules"
    shopId: ID!

    "Return results sorted in this order"
    sortOrder: SortOrder = asc,

    "By default, rules are sorted by when they were created, oldest first. Set this to sort by one of the other allowed fields"
    sortBy: AddressValidationRuleSortByField = createdAt
  ): AddressValidationRuleConnection!
}
