Improvements in GraphQL API coverage
GraphQL API surface area was extended and now includes a lot of new query fields and types, as well as experimental mutation support.
[GraphQL API] Added support for DiscountCode, CartDiscount and ProductDiscount. Following changes were introduced in the GraphQL schema:
extend type Query {discountCode(id: String!): DiscountCodediscountCodes(where: String, sort: [String!], limit: Int, offset: Int): DiscountCodeQueryResult!cartDiscount(id: String!): CartDiscountcartDiscounts(where: String, sort: [String!], limit: Int, offset: Int): CartDiscountQueryResult!productDiscount(id: String!): ProductDiscountproductDiscounts(where: String, sort: [String!], limit: Int, offset: Int): ProductDiscountQueryResult!}interface CartDiscountTarget {type: String!}interface CartDiscountValue {type: String!}interface ProductDiscountValue {type: String!}type AbsoluteDiscountValue implements CartDiscountValue, ProductDiscountValue {money: [Money!]!type: String!}type CartDiscount implements Versioned {id: String!version: Long!cartPredicate: String!validFrom: DateTimevalidUntil: DateTimestackingMode: StackingMode!isActive: Boolean!requiresDiscountCode: Boolean!sortOrder: String!createdAt: DateTime!lastModifiedAt: DateTime!name("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): Stringdescription("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringnameAllLocales: [LocalizedString!]!descriptionAllLocales: [LocalizedString!]value: CartDiscountValue!target: CartDiscountTarget}type CartDiscountQueryResult {offset: Int!count: Int!total: Long!results: [CartDiscount!]!}type DiscountCode implements Versioned {id: String!version: Long!code: String!isActive: Boolean!maxApplications: LongmaxApplicationsPerCustomer: LongcartPredicate: StringapplicationVersion: LongcreatedAt: DateTime!lastModifiedAt: DateTime!validFrom: DateTimevalidUntil: DateTimegroups: [String!]!name("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): Stringdescription("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringnameAllLocales: [LocalizedString!]descriptionAllLocales: [LocalizedString!]cartDiscounts: [CartDiscount!]!}type DiscountCodeQueryResult {offset: Int!count: Int!total: Long!results: [DiscountCode!]!}type ExternalDiscountValue implements ProductDiscountValue {type: String!}type LineItemsTarget implements CartDiscountTarget {predicate: String!type: String!}type MultiBuyCustomLineItemsTarget implements CartDiscountTarget {predicate: String!triggerQuantity: Int!discountedQuantity: Int!maxOccurrence: IntselectionMode: SelectionMode!type: String!}type MultiBuyLineItemsTarget implements CartDiscountTarget {predicate: String!triggerQuantity: Int!discountedQuantity: Int!maxOccurrence: IntselectionMode: SelectionMode!type: String!}type ProductDiscount implements Versioned {id: String!version: Long!predicate: String!validFrom: DateTimevalidUntil: DateTimeisActive: Boolean!isValid: Boolean!sortOrder: String!createdAt: DateTime!lastModifiedAt: DateTime!name("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): Stringdescription("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringnameAllLocales: [LocalizedString!]!descriptionAllLocales: [LocalizedString!]value: ProductDiscountValue!}type ProductDiscountQueryResult {offset: Int!count: Int!total: Long!results: [ProductDiscount!]!}type RelativeDiscountValue implements CartDiscountValue, ProductDiscountValue {permyriad: Int!type: String!}[GraphQL API] Added support for Type and CustomFields. Custom fields support is very similar to product attributes where the type-safe GraphQL models are created for project-specific
Type
definitions. At the moment custom fields are available only on theDiscountCode
and theCartDiscount
. Following changes were introduced in the GraphQL schema:extend type Query {typeDefinition(id: String!): TypeDefinitiontypeDefinitions(where: String, sort: [String!], limit: Int, offset: Int): TypeDefinitionQueryResult!}interface CustomField {name: String!}interface FieldType {name: String!}type BooleanField implements CustomField {value: Boolean!name: String!}type BooleanType implements FieldType {name: String!}type DateField implements CustomField {value: Date!name: String!}type DateTimeField implements CustomField {value: DateTime!name: String!}type DateTimeType implements FieldType {name: String!}type DateType implements FieldType {name: String!}type EnumField implements CustomField {key: String!label: String!name: String!}type EnumType implements FieldType {values: [EnumValue!]!name: String!}type EnumValue {key: String!label: String!}"Field definitions describe custom fields and allow you to define some meta-information associated with the field."type FieldDefinition {name: String!required: Boolean!inputHint: TextInputHint!label("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringlabelAllLocales: [LocalizedString!]!type: FieldType!}type LocalizedEnumField implements CustomField {key: String!label("String is define for different locales. This argument specifies the desired locale."locale: Locale!): Stringname: String!}type LocalizedEnumType implements FieldType {values: [LocalizedEnumValue!]!name: String!}type LocalizedEnumValue {key: String!label("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringlabelAllLocales: [LocalizedString!]!}type LocalizedString {locale: Locale!value: String!}type LocalizedStringField implements CustomField {value("String is define for different locales. This argument specifies the desired locale."locale: Locale!): Stringname: String!}type LocalizedStringType implements FieldType {name: String!}type MoneyField implements CustomField {centAmount: Long!currencyCode: Currency!name: String!}type MoneyType implements FieldType {name: String!}type NumberField implements CustomField {value: BigDecimal!name: String!}type NumberType implements FieldType {name: String!}type ProductReferenceIdentifier {typeId: String!id: Stringkey: String}type ReferenceField implements CustomField {typeId: String!id: String!name: String!}type ReferenceType implements FieldType {referenceTypeId: String!name: String!}type SetType implements FieldType {elementType: FieldType!name: String!}type ShippingTarget implements CartDiscountTarget {type: String!}type StringField implements CustomField {value: String!name: String!}type StringType implements FieldType {name: String!}type TimeField implements CustomField {value: Time!name: String!}type TimeType implements FieldType {name: String!}"Types define the structure of custom fields which can be attached to different entities that support them."type TypeDefinition implements Versioned {id: String!version: Long!key: String!fieldDefinitions: [FieldDefinition!]!createdAt: DateTime!lastModifiedAt: DateTime!name("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): Stringdescription("String is define for different locales. This argument specifies the desired locale."locale: Locale,"List of languages the client is able to understand, and which locale variant is preferred."acceptLanguage: [Locale!]): StringnameAllLocales: [LocalizedString!]!descriptionAllLocales: [LocalizedString!]resourceTypeIds: [String!]!}type TypeDefinitionQueryResult {offset: Int!count: Int!total: Long!results: [TypeDefinition!]!}[GraphQL API] Added support for
DiscountCode
mutation API. Please note that currently mutation API is experimental and subject to change. Following changes were introduced in the GraphQL schema:type Mutation {createDiscountCode(draft: DiscountCodeDraft!): DiscountCodeupdateDiscountCode(id: String!, version: Long!, actions: [DiscountCodeUpdateAction!]!): DiscountCodedeleteDiscountCode(id: String!, version: Long!): DiscountCode}input ChangeDiscountCodeCartDiscounts {cartDiscounts: [ReferenceInput!]!}input ChangeDiscountCodeGroups {groups: [String!]!}input ChangeDiscountCodeIsActive {isActive: Boolean!}input CustomFieldInput {name: String!value: String!}input CustomFieldsDraft {typeId: StringtypeKey: Stringtype: ResourceIdentifierInputfields: [CustomFieldInput!]}input DiscountCodeDraft {code: String!name: [LocalizedStringInput!]description: [LocalizedStringInput!]cartDiscounts: [ReferenceInput!]!isActive: Boolean = truemaxApplications: LongmaxApplicationsPerCustomer: LongcartPredicate: Stringcustom: CustomFieldsDraftvalidFrom: DateTimevalidUntil: DateTimegroups: [String!] = []}input DiscountCodeUpdateAction {setName: SetDiscountCodeNamesetDescription: SetDiscountCodeDescriptionsetCartPredicate: SetDiscountCodeCartPredicatesetMaxApplications: SetDiscountCodeMaxApplicationssetMaxApplicationsPerCustomer: SetDiscountCodeMaxApplicationsPerCustomerchangeCartDiscounts: ChangeDiscountCodeCartDiscountschangeIsActive: ChangeDiscountCodeIsActivesetCustomType: SetDiscountCodeCustomTypesetCustomField: SetDiscountCodeCustomFieldsetValidFrom: SetDiscountCodeValidFromsetValidUntil: SetDiscountCodeValidUntilchangeGroups: ChangeDiscountCodeGroups}input LocalizedStringInput {locale: Locale!value: String!}input LocalizedText {text: String!locale: Locale!}input ReferenceInput {typeId: String!id: String!}input ResourceIdentifierInput {id: Stringkey: String}input SetDiscountCodeCartPredicate {cartPredicate: String}input SetDiscountCodeCustomField {name: String!value: String}input SetDiscountCodeCustomType {typeId: StringtypeKey: Stringtype: ResourceIdentifierInputfields: [CustomFieldInput!]}input SetDiscountCodeDescription {description: [LocalizedStringInput!]}input SetDiscountCodeMaxApplications {maxApplications: Long}input SetDiscountCodeMaxApplicationsPerCustomer {maxApplicationsPerCustomer: Long}input SetDiscountCodeName {name: [LocalizedStringInput!]}input SetDiscountCodeValidFrom {validFrom: DateTime}input SetDiscountCodeValidUntil {validUntil: DateTime}