"""
App settings that are not shop specific. Plugins extend the GlobalSettings type to support
whatever settings they need.
"""
type GlobalSettings {
  "A fake setting necessary until some plugin extends this with a real setting"
  doNotUse: String
}

"""
App settings for a specific shop. Plugins extend the ShopSettings type to support
whatever settings they need.
"""
type ShopSettings {
  # Although the spec allows and Apollo supports defining an empty type
  # that is extended later in other files, the graphql-schema-linter
  # package currently has a problem with this, so we must add a fake field.
  #
  # https://github.com/cjoudrey/graphql-schema-linter/issues/151
  "A fake setting necessary until some plugin extends this with a real setting"
  doNotUse: String
}

extend type Query {
  """
  Returns app settings that are not shop specific. Plugins extend the GlobalSettings type to support
  whatever settings they need.
  """
  globalSettings: GlobalSettings!

  """
  Returns app settings for a specific shop. Plugins extend the ShopSettings type to support
  whatever settings they need.
  """
  shopSettings(
    "The shop to get app settings for"
    shopId: ID!
  ): ShopSettings!
}

##
# updateGlobalSettings
##

extend type Mutation {
  """
  Returns app settings that are not shop specific. Plugins extend the GlobalSettings type to support
  whatever settings they need.
  """
  updateGlobalSettings(
    "Mutation input"
    input: UpdateGlobalSettingsInput!
  ): UpdateGlobalSettingsPayload!
}

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

  "Updated settings values. Only includes settings to be changed."
  settingsUpdates: GlobalSettingsUpdates!
}

"""
Updates for app settings that are not shop specific. Plugins extend
this input type to support whatever settings they need. All fields
must be optional.
"""
input GlobalSettingsUpdates {
  "Do not use this field"
  doNotUse: String
}

"Response payload for the `updateGlobalSettings` mutation"
type UpdateGlobalSettingsPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "Updated global settings"
  globalSettings: GlobalSettings!
}

##
# updateShopSettings
##

extend type Mutation {
  """
  Returns app settings for a specific shop. Plugins extend the ShopSettings type to support
  whatever settings they need.
  """
  updateShopSettings(
    "Mutation input"
    input: UpdateShopSettingsInput!
  ): UpdateShopSettingsPayload!
}

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

  "Updated settings values. Only includes settings to be changed."
  settingsUpdates: ShopSettingsUpdates!

  "The ID of the shop to update some settings for"
  shopId: ID!
}

"""
Updates for app settings that are not shop specific. Plugins extend
this input type to support whatever settings they need. All fields
must be optional.
"""
input ShopSettingsUpdates {
  # Although the spec allows and Apollo supports defining an empty type
  # that is extended later in other files, the graphql-schema-linter
  # package currently has a problem with this, so we must add a fake field.
  #
  # https://github.com/cjoudrey/graphql-schema-linter/issues/151
  "Do not use this field"
  doNotUse: String
}

"Response payload for the `updateShopSettings` mutation"
type UpdateShopSettingsPayload {
  "The same string you sent with the mutation params, for matching mutation calls with their responses"
  clientMutationId: String

  "Updated shop settings"
  shopSettings: ShopSettings!
}
