Platform Release 20 August 2019

The customFields field on GraphQL queries is deprecated in favor of the new custom field. customFields is still available for use in queries, but we strongly encourage all users to switch to using custom in GraphQL queries. For more information about this change, see Beta Features.

We are deprecating the existing customFields graphQL field present on all fields having custom fields for a better alternative.

In the new approach, all fields having custom fields have the new custom field exposes the following sub-fields:

type RawCustomField {
  name: String!
  value: Json!
}

type CustomFieldsType {
  typeRef: Reference!
  type: TypeDefinition

  "This field contains non-typed data. For a typed alternative, have a look at `customFields`."
  customFieldsRaw(
    includeNames: [String!],
    excludeNames: [String!]): [RawCustomField!]

  "This field contains typed data"
  customFields: Type!
}

The customFields provides access to typed custom fields.

The new custom field improves the performance of the query as long as you don’t use typed fields. For example:

fragment customFields on ProducePrice {
  custom {
    typeRef { 
      id
    }
    rawCustomFields {
      name
      value
    }
  }
}

If you use custom.customFields then you won’t profit from the better performance.

Introduced the following changes to the GraphQL schema (in SDL format):

extend type Category {
  custom: CustomFieldsType
}

extend type Channel {
  custom: CustomFieldsType
}

extend type ProductPrice {
  custom: CustomFieldsType
}

extend type Cart {
  custom: CustomFieldsType
}

extend type CustomerGroup {
  custom: CustomFieldsType
}

extend type Asset {
  custom: CustomFieldsType
}

extend type CustomLineItem {
  custom: CustomFieldsType
}

extend type Customer {
  custom: CustomFieldsType
}

extend type CartDiscount {
  custom: CustomFieldsType
}

extend type Payment {
  custom: CustomFieldsType
}

extend type CategorySearch {
  custom: CustomFieldsType
}

extend type Order {
  custom: CustomFieldsType
}

extend type InventoryEntry {
  custom: CustomFieldsType
}

extend type LineItem {
  custom: CustomFieldsType
}

extend type DiscountCode {
  custom: CustomFieldsType
}

type CustomFieldsType {
  typeRef: Reference!
  type: TypeDefinition

  "This field contains non-typed data. For a typed alternative, have a look at `customFields`."
  customFieldsRaw(
    """
    The names of the custom fields to include.
    
    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    includeNames: [String!],

    """
    The names of the custom fields to exclude.
    
    If neither `includeNames` nor `excludeNames` are provided, then all custom fields are returned.
    """
    excludeNames: [String!]): [RawCustomField!]

  "This field contains typed data"
  customFields: Type!
}