####
# Custom data types for FlatRateFulfillmentRestriction data
####
"An attribute restriction condition"
type AttributeRestrictions {
  "The operator to use for value comparison"
  operator: String!

  "The property to check"
  property: String!

  "The type of this property"
  propertyType: String!

  "The value to check for"
  value: String!
}

"""
Destination restriction conditions. If multiple of `country`,
`region`, and `postal` are set, there is an AND relationship.
"""
type DestinationRestrictions {
  "Restrict for any of these destination countries"
  country: [String]

  "Restrict for any of these destination postal codes"
  postal: [String]

  "Restrict for any of these destination regions"
  region: [String]
}

"Restriction type"
enum RestrictionTypeEnum {
  "Allow"
  allow

  "Deny"
  deny
}

"Allowed values for `FlatRateFulfillmentRestriction` sortBy parameter"
enum FlatRateFulfillmentRestrictionSortByField {
  "Date the restriction was created"
  createdAt
}

"Input to create an attribute restriction condition"
input AttributeRestrictionsInput {
  "The operator to use for value comparison"
  operator: String!

  "The property to check"
  property: String!

  "The type of this property"
  propertyType: String!

  "The value to check for"
  value: String!
}

"Input for a destination restriction condition"
input DestinationRestrictionsInput {
  "Restrict for any of these destination countries"
  country: [String]

  "Restrict for any of these destination postal codes"
  postal: [String]

  "Restrict for any of these destination regions"
  region: [String]
}

####
# Queries
####
extend type Query {
  "Get the full list of flat rate fulfillment method restrictions."
  getFlatRateFulfillmentRestrictions(
    "Shop to get restrictions for"
    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,

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

    "By default, restrictions are sorted by when they were created, newest first. Set this to sort by one of the other allowed fields"
    sortBy: FlatRateFulfillmentRestrictionSortByField = createdAt
  ): FlatRateFulfillmentRestrictionConnection!

  "Get a single flat rate fulfillment method restriction."
  getFlatRateFulfillmentRestriction(
    "The restriction ID"
    restrictionId: ID!,

    "Shop that owns the restriction"
    shopId: ID!
  ): FlatRateFulfillmentRestriction
}

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

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

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

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

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

  "The flat rate fulfillment restriction"
  node: FlatRateFulfillmentRestriction
}

"Defines a flat rate fulfillment method restriction."
type FlatRateFulfillmentRestriction implements Node {
  "The restriction ID."
  _id: ID!

  "Attribute restrictions. Multiple attribute restrictions are evaluated with AND. If both destination and attribute restrictions are present, they evaluate with AND."
  attributes: [AttributeRestrictions]

  "Destination restrictions. If multiple destination restrictions are present, the most localized is the only one evaluated (i.e. evaluate postal if present, then region if present, then country). If both destination and attribute restrictions are present, they evaluate with AND."
  destination: DestinationRestrictions

  "Method IDs to apply this restriction to. If none, applies to all methods as a universal restriction."
  methodIds: [ID]

  "The shop ID"
  shopId: ID!

  """
  The type of this restriction. Allowed types are `allow` or `deny`.
  """
  type: RestrictionTypeEnum!
}

####
# Create restriction mutation
####
extend type Mutation {
  "Create a flat rate fulfillment method restriction."
  createFlatRateFulfillmentRestriction(
    "Mutation input"
    input: CreateFlatRateFulfillmentRestrictionInput!
  ): CreateFlatRateFulfillmentRestrictionPayload!
}

# Inputs
"Defines the input for a flat rate fulfillment method restriction."
input FlatRateFulfillmentRestrictionInput {
  "Attribute restrictions. Multiple attribute restrictions are evaluated with AND. If both destination and attribute restrictions are present, they evaluate with AND."
  attributes: [AttributeRestrictionsInput]

  "Destination restrictions. If multiple destination restrictions are present, the most localized is the only one evaluated (i.e. evaluate postal if present, then region if present, then country). If both destination and attribute restrictions are present, they evaluate with AND."
  destination: DestinationRestrictionsInput

  "Method IDs to apply this restriction to. If none, applies to all methods as a universal restriction."
  methodIds: [ID]

  """
  The type of this restriction. Allowed types are `allow` or `deny`.
  """
  type: RestrictionTypeEnum!
}

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

  "This defines the flat rate fulfillment method restriction that you want to create"
  restriction: FlatRateFulfillmentRestrictionInput!

  "The shop to create this flat rate fulfillment method restriction for"
  shopId: ID!
}


# Payloads
"Response from the `CreateFlatRateFulfillmentRestriction` mutation"
type CreateFlatRateFulfillmentRestrictionPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The created flat rate fulfillment method restriction"
  restriction: FlatRateFulfillmentRestriction!
}


####
# Delete restriction mutation
####
extend type Mutation {
  "Delete a flat rate fulfillment method restriction"
  deleteFlatRateFulfillmentRestriction(
    "Mutation input"
    input: DeleteFlatRateFulfillmentRestrictionInput!
  ): DeleteFlatRateFulfillmentRestrictionPayload!
}

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

  "The ID of the flat rate fulfillment method restriction you want to delete"
  restrictionId: ID!

  "The shop that owns the flat rate fulfillment method restriction"
  shopId: ID!
}

# Payloads
"Response from the `deleteFlatRateFulfillmentRestriction` mutation"
type DeleteFlatRateFulfillmentRestrictionPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The removed flat rate fulfillment method restriction"
  restriction: FlatRateFulfillmentRestriction!
}


####
# Update restriction mutation
####
extend type Mutation {
  "Update a flat rate fulfillment method restriction"
  updateFlatRateFulfillmentRestriction(
    "Mutation input"
    input: UpdateFlatRateFulfillmentRestrictionInput!
  ): UpdateFlatRateFulfillmentRestrictionPayload!
}

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

  "The updated flat rate fulfillment method restriction. Pass the whole updated restriction object without the ID."
  restriction: FlatRateFulfillmentRestrictionInput!

  "The ID of the flat rate fulfillment method restriction you want to update"
  restrictionId: ID!

  "The shop that owns the flat rate fulfillment method restriction"
  shopId: ID!
}

# Payloads
"Response from the `updateFlatRateFulfillmentMethod` mutation"
type UpdateFlatRateFulfillmentRestrictionPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "The updated flat rate fulfillment method restriction"
  restriction: FlatRateFulfillmentRestriction!
}
