From b64ca40af733e4de348da135e397ff86749b5932 Mon Sep 17 00:00:00 2001 From: Scott Allen <69159415+WildForkScott@users.noreply.github.com> Date: Tue, 17 May 2022 12:06:27 -0400 Subject: [PATCH 01/55] Create CODEOWNERS --- .github/CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..8d8b351b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# The following team is the owner for everything in the repo. Everyone in +# the team will be requested for review when someone opens a pull request. +* @wildfork/us-mobile-app From fd77948afc05baac6003a7598bd7f195a048ded4 Mon Sep 17 00:00:00 2001 From: tonylib Date: Tue, 17 May 2022 21:29:36 -0400 Subject: [PATCH 02/55] Remove availableQuantity as we do not use this variable from shopify. We track our own inventory using a different API. There is a special permission for reading availableQuantity and we do not want this value used by mistake so our Storefront API does not have access to it. --- example/pubspec.lock | 4 +-- ...et_all_products_from_collection_by_id.dart | 1 - .../queries/get_all_products_on_query.dart | 1 - .../queries/get_collections.dart | 1 - .../queries/get_featured_collections.dart | 1 - .../queries/get_n_products.dart | 1 - .../queries/get_product_recommendations.dart | 1 - .../queries/get_products.dart | 1 - .../queries/get_products_by_handle.dart | 3 +-- .../queries/get_products_by_ids.dart | 1 - ...t_x_collections_and_n_products_sorted.dart | 1 - .../queries/get_x_products_after_cursor.dart | 1 - ...oducts_after_cursor_within_collection.dart | 1 - .../get_x_products_on_query_after_cursor.dart | 1 - .../product_variant/product_variant.dart | 2 -- .../product_variant.freezed.dart | 26 +------------------ .../product_variant/product_variant.g.dart | 1 - pubspec.lock | 8 +++--- 18 files changed, 8 insertions(+), 48 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 170e77aa..cef8f319 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -145,7 +145,7 @@ packages: path: ".." relative: true source: path - version: "0.0.25-alpha" + version: "0.0.26-alpha" flutter_test: dependency: "direct dev" description: flutter @@ -618,4 +618,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + flutter: ">=2.10.0" diff --git a/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart b/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart index 935e00b5..9ad5e449 100644 --- a/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart +++ b/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart @@ -83,7 +83,6 @@ query($id : ID!, $cursor : String, $sortKey: ProductCollectionSortKeys){ } availableForSale id - quantityAvailable unitPrice { amount currencyCode diff --git a/lib/graphql_operations/queries/get_all_products_on_query.dart b/lib/graphql_operations/queries/get_all_products_on_query.dart index c7ffdf2c..998ed35c 100644 --- a/lib/graphql_operations/queries/get_all_products_on_query.dart +++ b/lib/graphql_operations/queries/get_all_products_on_query.dart @@ -57,7 +57,6 @@ query( $cursor: String, $sortKey : ProductSortKeys, $query: String, $reverse: Bo value } id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_collections.dart b/lib/graphql_operations/queries/get_collections.dart index 589cddca..45acf3e4 100644 --- a/lib/graphql_operations/queries/get_collections.dart +++ b/lib/graphql_operations/queries/get_collections.dart @@ -47,7 +47,6 @@ query($cursor: String, $sortKey: CollectionSortKeys, $reverse: Boolean){ value } availableForSale - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_featured_collections.dart b/lib/graphql_operations/queries/get_featured_collections.dart index 85e5ab4e..322bf5f2 100644 --- a/lib/graphql_operations/queries/get_featured_collections.dart +++ b/lib/graphql_operations/queries/get_featured_collections.dart @@ -39,7 +39,6 @@ query getFeaturedCollectionQuery($query: String!){ sku requiresShipping availableForSale - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_n_products.dart b/lib/graphql_operations/queries/get_n_products.dart index eff74cf3..ac066aff 100644 --- a/lib/graphql_operations/queries/get_n_products.dart +++ b/lib/graphql_operations/queries/get_n_products.dart @@ -35,7 +35,6 @@ query($n : Int, $sortKey : ProductSortKeys, $reverse: Boolean){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_product_recommendations.dart b/lib/graphql_operations/queries/get_product_recommendations.dart index 711f1cc2..7820d037 100644 --- a/lib/graphql_operations/queries/get_product_recommendations.dart +++ b/lib/graphql_operations/queries/get_product_recommendations.dart @@ -51,7 +51,6 @@ query getProductRecommentationsQuery($id: ID!){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_products.dart b/lib/graphql_operations/queries/get_products.dart index cdbe90b6..32934a92 100644 --- a/lib/graphql_operations/queries/get_products.dart +++ b/lib/graphql_operations/queries/get_products.dart @@ -47,7 +47,6 @@ query($cursor : String, $metafieldsNamespace : String){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_products_by_handle.dart b/lib/graphql_operations/queries/get_products_by_handle.dart index 920461fe..c7d90f74 100644 --- a/lib/graphql_operations/queries/get_products_by_handle.dart +++ b/lib/graphql_operations/queries/get_products_by_handle.dart @@ -17,10 +17,9 @@ query getProductByHandle($handle : String!){ amount currencyCode } - quantityAvailable } } } } } -'''; \ No newline at end of file +'''; diff --git a/lib/graphql_operations/queries/get_products_by_ids.dart b/lib/graphql_operations/queries/get_products_by_ids.dart index 8a014ea1..c753aeba 100644 --- a/lib/graphql_operations/queries/get_products_by_ids.dart +++ b/lib/graphql_operations/queries/get_products_by_ids.dart @@ -62,7 +62,6 @@ query($ids : [ID!]!){ value } id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart b/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart index 61fbd2e4..8c87869e 100644 --- a/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart +++ b/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart @@ -47,7 +47,6 @@ query($cursor: String, $sortKey: CollectionSortKeys, $sortKeyProduct: ProductCol value } availableForSale - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_products_after_cursor.dart b/lib/graphql_operations/queries/get_x_products_after_cursor.dart index 53fc80eb..d5eff096 100644 --- a/lib/graphql_operations/queries/get_x_products_after_cursor.dart +++ b/lib/graphql_operations/queries/get_x_products_after_cursor.dart @@ -35,7 +35,6 @@ query($cursor : String, $x : Int, $reverse: Boolean, $sortKey: ProductSortKeys){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart b/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart index d2cc95ff..eb584969 100644 --- a/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart +++ b/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart @@ -83,7 +83,6 @@ query($id : ID!, $cursor : String, $limit : Int, $sortKey : ProductCollectionSor } availableForSale id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart b/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart index 1e630814..a7ddcc5d 100644 --- a/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart +++ b/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart @@ -57,7 +57,6 @@ query( $cursor: String, $limit : Int, $sortKey : ProductSortKeys, $query: String value } id - quantityAvailable } } } diff --git a/lib/models/src/product/product_variant/product_variant.dart b/lib/models/src/product/product_variant/product_variant.dart index 10cb6414..fa0e9ca8 100644 --- a/lib/models/src/product/product_variant/product_variant.dart +++ b/lib/models/src/product/product_variant/product_variant.dart @@ -19,7 +19,6 @@ class ProductVariant with _$ProductVariant { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -45,7 +44,6 @@ class ProductVariant with _$ProductVariant { sku: nodeJson['sku'], requiresShipping: nodeJson['requiresShipping'], id: nodeJson['id'], - quantityAvailable: nodeJson['quantityAvailable'], unitPrice: nodeJson['unitPrice'] != null ? PriceV2.fromJson(nodeJson['unitPrice']) : null, diff --git a/lib/models/src/product/product_variant/product_variant.freezed.dart b/lib/models/src/product/product_variant/product_variant.freezed.dart index fd063b44..60611fb8 100644 --- a/lib/models/src/product/product_variant/product_variant.freezed.dart +++ b/lib/models/src/product/product_variant/product_variant.freezed.dart @@ -31,7 +31,6 @@ class _$ProductVariantTearOff { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -46,7 +45,6 @@ class _$ProductVariantTearOff { sku: sku, requiresShipping: requiresShipping, id: id, - quantityAvailable: quantityAvailable, unitPrice: unitPrice, unitPriceMeasurement: unitPriceMeasurement, selectedOptions: selectedOptions, @@ -73,7 +71,6 @@ mixin _$ProductVariant { String get sku => throw _privateConstructorUsedError; bool get requiresShipping => throw _privateConstructorUsedError; String get id => throw _privateConstructorUsedError; - int get quantityAvailable => throw _privateConstructorUsedError; PriceV2? get unitPrice => throw _privateConstructorUsedError; UnitPriceMeasurement? get unitPriceMeasurement => throw _privateConstructorUsedError; @@ -102,7 +99,6 @@ abstract class $ProductVariantCopyWith<$Res> { String sku, bool requiresShipping, String id, - int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -135,7 +131,6 @@ class _$ProductVariantCopyWithImpl<$Res> Object? sku = freezed, Object? requiresShipping = freezed, Object? id = freezed, - Object? quantityAvailable = freezed, Object? unitPrice = freezed, Object? unitPriceMeasurement = freezed, Object? selectedOptions = freezed, @@ -175,10 +170,6 @@ class _$ProductVariantCopyWithImpl<$Res> ? _value.id : id // ignore: cast_nullable_to_non_nullable as String, - quantityAvailable: quantityAvailable == freezed - ? _value.quantityAvailable - : quantityAvailable // ignore: cast_nullable_to_non_nullable - as int, unitPrice: unitPrice == freezed ? _value.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable @@ -271,7 +262,6 @@ abstract class _$ProductVariantCopyWith<$Res> String sku, bool requiresShipping, String id, - int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -311,7 +301,6 @@ class __$ProductVariantCopyWithImpl<$Res> Object? sku = freezed, Object? requiresShipping = freezed, Object? id = freezed, - Object? quantityAvailable = freezed, Object? unitPrice = freezed, Object? unitPriceMeasurement = freezed, Object? selectedOptions = freezed, @@ -351,10 +340,6 @@ class __$ProductVariantCopyWithImpl<$Res> ? _value.id : id // ignore: cast_nullable_to_non_nullable as String, - quantityAvailable: quantityAvailable == freezed - ? _value.quantityAvailable - : quantityAvailable // ignore: cast_nullable_to_non_nullable - as int, unitPrice: unitPrice == freezed ? _value.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable @@ -391,7 +376,6 @@ class _$_ProductVariant extends _ProductVariant { required this.sku, required this.requiresShipping, required this.id, - required this.quantityAvailable, this.unitPrice, this.unitPriceMeasurement, this.selectedOptions, @@ -419,8 +403,6 @@ class _$_ProductVariant extends _ProductVariant { @override final String id; @override - final int quantityAvailable; - @override final PriceV2? unitPrice; @override final UnitPriceMeasurement? unitPriceMeasurement; @@ -433,7 +415,7 @@ class _$_ProductVariant extends _ProductVariant { @override String toString() { - return 'ProductVariant(price: $price, title: $title, weight: $weight, weightUnit: $weightUnit, availableForSale: $availableForSale, sku: $sku, requiresShipping: $requiresShipping, id: $id, quantityAvailable: $quantityAvailable, unitPrice: $unitPrice, unitPriceMeasurement: $unitPriceMeasurement, selectedOptions: $selectedOptions, compareAtPrice: $compareAtPrice, image: $image)'; + return 'ProductVariant(price: $price, title: $title, weight: $weight, weightUnit: $weightUnit, availableForSale: $availableForSale, sku: $sku, requiresShipping: $requiresShipping, id: $id, unitPrice: $unitPrice, unitPriceMeasurement: $unitPriceMeasurement, selectedOptions: $selectedOptions, compareAtPrice: $compareAtPrice, image: $image)'; } @override @@ -452,8 +434,6 @@ class _$_ProductVariant extends _ProductVariant { const DeepCollectionEquality() .equals(other.requiresShipping, requiresShipping) && const DeepCollectionEquality().equals(other.id, id) && - const DeepCollectionEquality() - .equals(other.quantityAvailable, quantityAvailable) && const DeepCollectionEquality().equals(other.unitPrice, unitPrice) && const DeepCollectionEquality() .equals(other.unitPriceMeasurement, unitPriceMeasurement) && @@ -475,7 +455,6 @@ class _$_ProductVariant extends _ProductVariant { const DeepCollectionEquality().hash(sku), const DeepCollectionEquality().hash(requiresShipping), const DeepCollectionEquality().hash(id), - const DeepCollectionEquality().hash(quantityAvailable), const DeepCollectionEquality().hash(unitPrice), const DeepCollectionEquality().hash(unitPriceMeasurement), const DeepCollectionEquality().hash(selectedOptions), @@ -503,7 +482,6 @@ abstract class _ProductVariant extends ProductVariant { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -531,8 +509,6 @@ abstract class _ProductVariant extends ProductVariant { @override String get id; @override - int get quantityAvailable; - @override PriceV2? get unitPrice; @override UnitPriceMeasurement? get unitPriceMeasurement; diff --git a/lib/models/src/product/product_variant/product_variant.g.dart b/lib/models/src/product/product_variant/product_variant.g.dart index a1de48ae..63b10359 100644 --- a/lib/models/src/product/product_variant/product_variant.g.dart +++ b/lib/models/src/product/product_variant/product_variant.g.dart @@ -45,7 +45,6 @@ Map _$$_ProductVariantToJson(_$_ProductVariant instance) => 'sku': instance.sku, 'requiresShipping': instance.requiresShipping, 'id': instance.id, - 'quantityAvailable': instance.quantityAvailable, 'unitPrice': instance.unitPrice, 'unitPriceMeasurement': instance.unitPriceMeasurement, 'selectedOptions': instance.selectedOptions, diff --git a/pubspec.lock b/pubspec.lock index 8044c08b..48510a9c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -449,7 +449,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -519,7 +519,7 @@ packages: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: @@ -547,7 +547,7 @@ packages: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shelf: dependency: transitive description: @@ -751,4 +751,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + flutter: ">=2.10.0" From a340b2052a5d61c23482c9db7a35022962bbf6e0 Mon Sep 17 00:00:00 2001 From: tonylib Date: Tue, 17 May 2022 21:47:33 -0400 Subject: [PATCH 03/55] finish remove qty avail --- lib/models/src/product/product_variant/product_variant.g.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/models/src/product/product_variant/product_variant.g.dart b/lib/models/src/product/product_variant/product_variant.g.dart index 63b10359..1c3f512d 100644 --- a/lib/models/src/product/product_variant/product_variant.g.dart +++ b/lib/models/src/product/product_variant/product_variant.g.dart @@ -16,7 +16,6 @@ _$_ProductVariant _$$_ProductVariantFromJson(Map json) => sku: json['sku'] as String, requiresShipping: json['requiresShipping'] as bool, id: json['id'] as String, - quantityAvailable: json['quantityAvailable'] as int, unitPrice: json['unitPrice'] == null ? null : PriceV2.fromJson(json['unitPrice'] as Map), From 3f969d580011352b0c2e9557078aae9986789cb9 Mon Sep 17 00:00:00 2001 From: "komal.akhani" Date: Wed, 18 May 2022 15:12:58 +0530 Subject: [PATCH 04/55] created method for getting metafields --- example/pubspec.lock | 4 ++-- .../queries/get_customer.dart | 6 ++++++ lib/shopify/src/shopify_customer.dart | 18 ++++++++++++++++++ pubspec.lock | 8 ++++---- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 170e77aa..cef8f319 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -145,7 +145,7 @@ packages: path: ".." relative: true source: path - version: "0.0.25-alpha" + version: "0.0.26-alpha" flutter_test: dependency: "direct dev" description: flutter @@ -618,4 +618,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + flutter: ">=2.10.0" diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 46ba3faf..5929e3bc 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,6 +49,12 @@ query($customerAccessToken : String!){ firstName id lastName + metafields{ + id + key + value + namespace + } lastIncompleteCheckout { completedAt createdAt diff --git a/lib/shopify/src/shopify_customer.dart b/lib/shopify/src/shopify_customer.dart index 1e5f13ba..ef1b1a6e 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -2,10 +2,13 @@ import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_add import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_address_delete.dart'; import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_address_update.dart'; import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_update.dart'; +import 'package:flutter_simple_shopify/graphql_operations/queries/get_customer.dart'; import 'package:flutter_simple_shopify/mixins/src/shopfiy_error.dart'; +import 'package:flutter_simple_shopify/models/src/product/metafield/metafield.dart'; import 'package:flutter_simple_shopify/models/src/shopify_user/address/address.dart'; import 'package:graphql/client.dart'; +import '../../models/src/shopify_user/shopify_user.dart'; import '../../shopify_config.dart'; /// ShopifyCustomer class provides various methods for working with a user/customer. @@ -92,7 +95,22 @@ class ShopifyCustomer with ShopifyError { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } } + Future getCustomerMetaFields(String? customerAccessToken) async{ + // call query to get customer metafields + final MutationOptions _options = MutationOptions( + document: gql(customerAddressDeleteMutation), + variables: { + 'customerAccessToken': customerAccessToken, + //'id': addressId + }); + /* final WatchQueryOptions _getCustomer = WatchQueryOptions( + document: gql(getCustomerQuery), + variables: {'customerAccessToken': await customerAccessToken});*/ + final QueryResult result = (await _graphQLClient!.mutate(_options)); + checkForError(result); + return Metafield.fromJson(result.data!['metafields']); + } /// Creates a address for the customer to which [customerAccessToken] belongs to. Future
customerAddressCreate( {String? address1, diff --git a/pubspec.lock b/pubspec.lock index 8044c08b..48510a9c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -449,7 +449,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -519,7 +519,7 @@ packages: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: @@ -547,7 +547,7 @@ packages: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shelf: dependency: transitive description: @@ -751,4 +751,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + flutter: ">=2.10.0" From 54b10d230af587ef112b2a18f7061e811777520f Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 18 May 2022 16:54:43 +0530 Subject: [PATCH 05/55] query parameter changes. --- lib/shopify/src/shopify_customer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shopify/src/shopify_customer.dart b/lib/shopify/src/shopify_customer.dart index ef1b1a6e..b5e59316 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -98,7 +98,7 @@ class ShopifyCustomer with ShopifyError { Future getCustomerMetaFields(String? customerAccessToken) async{ // call query to get customer metafields final MutationOptions _options = MutationOptions( - document: gql(customerAddressDeleteMutation), + document: gql(getCustomerQuery), variables: { 'customerAccessToken': customerAccessToken, //'id': addressId From c79c7ee2e01b17bc9d0383af8baae9c1408546d6 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 18 May 2022 17:29:45 +0530 Subject: [PATCH 06/55] id parameter removed for testing. --- lib/graphql_operations/queries/get_customer.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 5929e3bc..8684e267 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -50,7 +50,6 @@ query($customerAccessToken : String!){ id lastName metafields{ - id key value namespace From f3b4e86a67b43396bdebdd30f677cb0ceebaaec9 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 18 May 2022 18:05:21 +0530 Subject: [PATCH 07/55] id parameter added. --- lib/graphql_operations/queries/get_customer.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 8684e267..5929e3bc 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -50,6 +50,7 @@ query($customerAccessToken : String!){ id lastName metafields{ + id key value namespace From 11acc8e2807d07a030d0a03d8a466e88835347f6 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 18 May 2022 22:45:33 +0530 Subject: [PATCH 08/55] node added in get_customer.dart. --- lib/graphql_operations/queries/get_customer.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 5929e3bc..2d430057 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,11 +49,13 @@ query($customerAccessToken : String!){ firstName id lastName - metafields{ - id - key - value - namespace + metafields { + nodes { + id + key + namespace + value + } } lastIncompleteCheckout { completedAt From 4fe73dc9729e80f0f1de2eaf22cba7ed699c80c1 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 18 May 2022 23:54:17 +0530 Subject: [PATCH 09/55] Metafield changes. --- lib/graphql_operations/queries/get_customer.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 2d430057..8aa03056 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,13 +49,11 @@ query($customerAccessToken : String!){ firstName id lastName - metafields { - nodes { - id - key - namespace - value - } + metafield(key: "", namespace: "") { + id + key + value + namespace } lastIncompleteCheckout { completedAt From ab38ba4833a9c484d700a2cd30601b43bdeb7938 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 19 May 2022 10:32:32 +0530 Subject: [PATCH 10/55] node added in get_customer.dart. --- lib/graphql_operations/queries/get_customer.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 8aa03056..49e6f8e1 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,11 +49,14 @@ query($customerAccessToken : String!){ firstName id lastName - metafield(key: "", namespace: "") { - id - key - value - namespace + metafields { + edges + nodes { + id + key + namespace + value + } } lastIncompleteCheckout { completedAt From b4c455ce7397c5b07e9a2e1d153fc1779e9b34c8 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Sat, 21 May 2022 00:30:48 +0530 Subject: [PATCH 11/55] curley bracket added in metafield. --- lib/graphql_operations/queries/get_customer.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 49e6f8e1..d7279712 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -50,12 +50,13 @@ query($customerAccessToken : String!){ id lastName metafields { - edges + edges { nodes { id key namespace value + } } } lastIncompleteCheckout { From 85449e97e27ea7ebec98cb8a7300da4775a22a94 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Sat, 21 May 2022 00:40:29 +0530 Subject: [PATCH 12/55] s removed from nodes. --- lib/graphql_operations/queries/get_customer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index d7279712..fdf7eb3f 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -51,7 +51,7 @@ query($customerAccessToken : String!){ lastName metafields { edges { - nodes { + node { id key namespace From bdc8dbe72d600fc8b4804b61ced34dd2aadecfb5 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Sat, 21 May 2022 01:24:04 +0530 Subject: [PATCH 13/55] first limit added. --- lib/graphql_operations/queries/get_customer.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index fdf7eb3f..6035f6b1 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,7 +49,7 @@ query($customerAccessToken : String!){ firstName id lastName - metafields { + metafields(first:250) { edges { node { id From 0ffa0ca076dcd65ab359f56b13042595ee501628 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Mon, 23 May 2022 16:32:59 +0530 Subject: [PATCH 14/55] customer metafield added in return method of get metafields. --- lib/shopify/src/shopify_customer.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/shopify/src/shopify_customer.dart b/lib/shopify/src/shopify_customer.dart index b5e59316..21522c68 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -97,19 +97,19 @@ class ShopifyCustomer with ShopifyError { } Future getCustomerMetaFields(String? customerAccessToken) async{ // call query to get customer metafields - final MutationOptions _options = MutationOptions( + /*final MutationOptions _options = MutationOptions( document: gql(getCustomerQuery), variables: { 'customerAccessToken': customerAccessToken, //'id': addressId - }); - /* final WatchQueryOptions _getCustomer = WatchQueryOptions( + });*/ + final WatchQueryOptions _getCustomer = WatchQueryOptions( document: gql(getCustomerQuery), - variables: {'customerAccessToken': await customerAccessToken});*/ - final QueryResult result = (await _graphQLClient!.mutate(_options)); + variables: {'customerAccessToken': await customerAccessToken}); + final QueryResult result = (await _graphQLClient!.query(_getCustomer)); checkForError(result); - return Metafield.fromJson(result.data!['metafields']); + return Metafield.fromJson(result.data!['customer']['metafields']); } /// Creates a address for the customer to which [customerAccessToken] belongs to. Future
customerAddressCreate( From 0d22a0ede25aae49e9a803ce7bc9edd450a5c590 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 25 May 2022 00:22:28 +0530 Subject: [PATCH 15/55] Storefront API mutation added. --- .../allow_storefront_api_access.dart | 22 +++++++++++++++++++ lib/shopify/src/shopify_product.dart | 21 ++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 lib/graphql_operations/mutations/allow_storefront_api_access.dart create mode 100644 lib/shopify/src/shopify_product.dart diff --git a/lib/graphql_operations/mutations/allow_storefront_api_access.dart b/lib/graphql_operations/mutations/allow_storefront_api_access.dart new file mode 100644 index 00000000..15866556 --- /dev/null +++ b/lib/graphql_operations/mutations/allow_storefront_api_access.dart @@ -0,0 +1,22 @@ +const String allowStoreFrontApiMutation = r''' +mutation { + metafieldStorefrontVisibilityCreate( + input: { + namespace: "wildfox" + key: "country_of_origin" + ownerType: PRODUCT + } + ) { + metafieldStorefrontVisibility { + id + key + namespace + value + } + userErrors { + field + message + } + } +} +'''; \ No newline at end of file diff --git a/lib/shopify/src/shopify_product.dart b/lib/shopify/src/shopify_product.dart new file mode 100644 index 00000000..242bad92 --- /dev/null +++ b/lib/shopify/src/shopify_product.dart @@ -0,0 +1,21 @@ +import 'package:graphql/client.dart'; +import '../../graphql_operations/mutations/allow_storefront_api_access.dart'; +import '../../mixins/src/shopfiy_error.dart'; +import '../../shopify_config.dart'; + +class ShopifyProduct with ShopifyError{ + + ShopifyProduct._(); + + static final ShopifyProduct instance = ShopifyProduct._(); + + GraphQLClient? get _graphQLClient => ShopifyConfig.graphQLClient; + + Future allowStoreFrontApi() async{ + final MutationOptions _options = MutationOptions( + document: gql(allowStoreFrontApiMutation), + ); + final QueryResult result = (await _graphQLClient!.mutate(_options)); + checkForError(result); + } +} \ No newline at end of file From 9d351ab59c33ff42205cf22988364e3b80553a2a Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Mon, 6 Jun 2022 23:53:20 +0530 Subject: [PATCH 16/55] get metafield query added. --- lib/graphql_operations/queries/get_meta_field.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/graphql_operations/queries/get_meta_field.dart diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart new file mode 100644 index 00000000..770ed605 --- /dev/null +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -0,0 +1,14 @@ +const String get_meta_field = r''' +query($id : String){ + productMetafields(id: $id) { + metafields(namespace: "wildFox", first: 10) { + edges + nodes { + namespace + key + value + } + } + } +} +'''; \ No newline at end of file From f28eb1bf9ca1801a2414056405c7caf34cabffbe Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Mon, 6 Jun 2022 23:57:04 +0530 Subject: [PATCH 17/55] Get meta field method added. --- lib/shopify/src/shopify_store.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index df6a2fd2..83dfff84 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -4,6 +4,7 @@ import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_collec import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_products_from_collection_by_id.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_products_on_query.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_collections_by_ids.dart'; +import 'package:flutter_simple_shopify/graphql_operations/queries/get_meta_field.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_metafileds_from_product.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_product_recommendations.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_products_by_ids.dart'; @@ -445,4 +446,19 @@ class ShopifyStore with ShopifyError { .map((e) => Metafield.fromGraphJson(e as Map)) .toList(); } + + Future> getMetaFields( + String id) async { + final WatchQueryOptions _options = WatchQueryOptions( + document: gql(get_meta_field), + variables: {'id': id}); + final QueryResult result = + await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); + return (result.data!['product']['metafields']['edges'] + as List) + .map((e) => Metafield.fromGraphJson(e as Map)) + .toList(); + + } } From 775da62df3877dfd17b3d6c53d6e71489ee959d2 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 12:12:30 +0530 Subject: [PATCH 18/55] minor changes --- example/pubspec.lock | 18 +++++++++--------- pubspec.lock | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index cef8f319..8ffef529 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -91,7 +91,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -119,7 +119,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -260,7 +260,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -295,7 +295,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -323,7 +323,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: @@ -468,7 +468,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -503,7 +503,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -580,7 +580,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" watcher: dependency: transitive description: @@ -617,5 +617,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.10.0" diff --git a/pubspec.lock b/pubspec.lock index 48510a9c..3b8cda15 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -140,7 +140,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -168,7 +168,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -344,7 +344,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -379,7 +379,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -414,7 +414,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: @@ -587,7 +587,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -629,7 +629,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" timing: dependency: transitive description: @@ -713,7 +713,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" watcher: dependency: transitive description: @@ -750,5 +750,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.15.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.10.0" From 797c01fa070e5eca8ebe13ed6b15191089790f00 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 12:27:37 +0530 Subject: [PATCH 19/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 770ed605..746f2615 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,6 +1,6 @@ const String get_meta_field = r''' query($id : String){ - productMetafields(id: $id) { + product(id: $id) { metafields(namespace: "wildFox", first: 10) { edges nodes { From 23c37408ce31ddf7acdd52b162474866b2e02a0c Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 12:36:28 +0530 Subject: [PATCH 20/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 746f2615..835c4c84 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -2,11 +2,12 @@ const String get_meta_field = r''' query($id : String){ product(id: $id) { metafields(namespace: "wildFox", first: 10) { - edges - nodes { - namespace - key - value + edges { + node { + namespace + key + value + } } } } From 5e96260dbfc8baa11b78f15246b243460b1c9ac4 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 12:43:41 +0530 Subject: [PATCH 21/55] Minor change in ID. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 835c4c84..3a2485cb 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,5 +1,5 @@ const String get_meta_field = r''' -query($id : String){ +query($id : ID!){ product(id: $id) { metafields(namespace: "wildFox", first: 10) { edges { From 9973c8022712496bcb64a71ab2669c39349058aa Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 13:01:57 +0530 Subject: [PATCH 22/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 3 ++- lib/shopify/src/shopify_store.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 3a2485cb..fec12b67 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,9 +1,10 @@ -const String get_meta_field = r''' +const String getMetaField = r''' query($id : ID!){ product(id: $id) { metafields(namespace: "wildFox", first: 10) { edges { node { + id namespace key value diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 83dfff84..6268a0e5 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -450,7 +450,7 @@ class ShopifyStore with ShopifyError { Future> getMetaFields( String id) async { final WatchQueryOptions _options = WatchQueryOptions( - document: gql(get_meta_field), + document: gql(getMetaField), variables: {'id': id}); final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); From 4c78aa1babb9cecb5cca17590acf39d3e827e495 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 13:24:44 +0530 Subject: [PATCH 23/55] Minor change in query. --- lib/shopify/src/shopify_store.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 6268a0e5..3fbe23ee 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -448,12 +448,15 @@ class ShopifyStore with ShopifyError { } Future> getMetaFields( - String id) async { + String id, {bool deleteThisPartOfCache = false}) async { final WatchQueryOptions _options = WatchQueryOptions( document: gql(getMetaField), variables: {'id': id}); final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); + if (deleteThisPartOfCache) { + _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); + } checkForError(result); return (result.data!['product']['metafields']['edges'] as List) From 0ca6debc6b6668aa45701177bb7a39845c5e54c1 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 13:25:19 +0530 Subject: [PATCH 24/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index fec12b67..0489878d 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,7 +1,7 @@ const String getMetaField = r''' query($id : ID!){ product(id: $id) { - metafields(namespace: "wildFox", first: 10) { + metafields(namespace: "wildFox", first: 3) { edges { node { id From 8020f0c67af5bd417dfe25dba25cc21a10fa4a49 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 14:10:33 +0530 Subject: [PATCH 25/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 0489878d..b564aab8 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,5 +1,5 @@ const String getMetaField = r''' -query($id : ID!){ +query ProductMetafields($id : ID!){ product(id: $id) { metafields(namespace: "wildFox", first: 3) { edges { From 063aa995513669c452220d84cc7d50cd90c28553 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 14:27:09 +0530 Subject: [PATCH 26/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- lib/shopify/src/shopify_store.dart | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index b564aab8..d5ee9892 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,7 +1,7 @@ const String getMetaField = r''' query ProductMetafields($id : ID!){ product(id: $id) { - metafields(namespace: "wildFox", first: 3) { + metafields(namespace: "wildfox", first: 3) { edges { node { id diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 3fbe23ee..8e1b0f7b 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -451,7 +451,10 @@ class ShopifyStore with ShopifyError { String id, {bool deleteThisPartOfCache = false}) async { final WatchQueryOptions _options = WatchQueryOptions( document: gql(getMetaField), - variables: {'id': id}); + variables: { + 'namespace': "wildfox", + 'key':'country_of_origin', + 'ownerId': "gid://shopify/Product/6662536396859"}); final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); if (deleteThisPartOfCache) { From e793e6b3293e1607ec2ebfe498bea7710d655211 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 16:17:19 +0530 Subject: [PATCH 27/55] Minor change in query. --- lib/shopify/src/shopify_store.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 8e1b0f7b..cecdbe9b 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -452,15 +452,13 @@ class ShopifyStore with ShopifyError { final WatchQueryOptions _options = WatchQueryOptions( document: gql(getMetaField), variables: { - 'namespace': "wildfox", - 'key':'country_of_origin', 'ownerId': "gid://shopify/Product/6662536396859"}); final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); if (deleteThisPartOfCache) { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } - checkForError(result); return (result.data!['product']['metafields']['edges'] as List) .map((e) => Metafield.fromGraphJson(e as Map)) From 6058cef1d2ef1760c205a5a8393edc77cb94bd32 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 16:33:26 +0530 Subject: [PATCH 28/55] Minor change in query. --- lib/graphql_operations/queries/get_meta_field.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index d5ee9892..5a846d77 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,6 +1,6 @@ const String getMetaField = r''' -query ProductMetafields($id : ID!){ - product(id: $id) { +query ProductMetafields($ownerId : ID!){ + product(id: $ownerId) { metafields(namespace: "wildfox", first: 3) { edges { node { From 6f07371bdab243ee23e83c63b2bc60c919aa4e44 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 16:41:09 +0530 Subject: [PATCH 29/55] Minor change in query. --- lib/shopify/src/shopify_store.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index cecdbe9b..f0455db4 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -460,7 +460,7 @@ class ShopifyStore with ShopifyError { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } return (result.data!['product']['metafields']['edges'] - as List) + as List) .map((e) => Metafield.fromGraphJson(e as Map)) .toList(); From 7b2571d8d7536d883544973325c3425dfae4851a Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 17:00:39 +0530 Subject: [PATCH 30/55] Minor change in query. --- .../queries/get_meta_field.dart | 2 ++ .../src/product/metafield/metafield.dart | 2 +- .../product/metafield/metafield.freezed.dart | 18 +++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 5a846d77..f7172f1c 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -8,6 +8,8 @@ query ProductMetafields($ownerId : ID!){ namespace key value + valueType + description } } } diff --git a/lib/models/src/product/metafield/metafield.dart b/lib/models/src/product/metafield/metafield.dart index d924b1ef..bdd99d3f 100644 --- a/lib/models/src/product/metafield/metafield.dart +++ b/lib/models/src/product/metafield/metafield.dart @@ -13,7 +13,7 @@ class Metafield with _$Metafield { required String key, required String value, required String valueType, - @Default('') String description, + @Default('') String? description, }) = _Metafield; static Metafield fromGraphJson(Map json) { diff --git a/lib/models/src/product/metafield/metafield.freezed.dart b/lib/models/src/product/metafield/metafield.freezed.dart index cffd8cd2..2f15afa7 100644 --- a/lib/models/src/product/metafield/metafield.freezed.dart +++ b/lib/models/src/product/metafield/metafield.freezed.dart @@ -28,7 +28,7 @@ class _$MetafieldTearOff { required String key, required String value, required String valueType, - String description = ''}) { + String? description = ''}) { return _Metafield( id: id, namespace: namespace, @@ -54,7 +54,7 @@ mixin _$Metafield { String get key => throw _privateConstructorUsedError; String get value => throw _privateConstructorUsedError; String get valueType => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; + String? get description => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -72,7 +72,7 @@ abstract class $MetafieldCopyWith<$Res> { String key, String value, String valueType, - String description}); + String? description}); } /// @nodoc @@ -116,7 +116,7 @@ class _$MetafieldCopyWithImpl<$Res> implements $MetafieldCopyWith<$Res> { description: description == freezed ? _value.description : description // ignore: cast_nullable_to_non_nullable - as String, + as String?, )); } } @@ -133,7 +133,7 @@ abstract class _$MetafieldCopyWith<$Res> implements $MetafieldCopyWith<$Res> { String key, String value, String valueType, - String description}); + String? description}); } /// @nodoc @@ -178,7 +178,7 @@ class __$MetafieldCopyWithImpl<$Res> extends _$MetafieldCopyWithImpl<$Res> description: description == freezed ? _value.description : description // ignore: cast_nullable_to_non_nullable - as String, + as String?, )); } } @@ -210,7 +210,7 @@ class _$_Metafield extends _Metafield { final String valueType; @JsonKey() @override - final String description; + final String? description; @override String toString() { @@ -259,7 +259,7 @@ abstract class _Metafield extends Metafield { required String key, required String value, required String valueType, - String description}) = _$_Metafield; + String? description}) = _$_Metafield; _Metafield._() : super._(); factory _Metafield.fromJson(Map json) = @@ -276,7 +276,7 @@ abstract class _Metafield extends Metafield { @override String get valueType; @override - String get description; + String? get description; @override @JsonKey(ignore: true) _$MetafieldCopyWith<_Metafield> get copyWith => From 4ed0c9884034586bb1cdbb9ccf779f453b67119f Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 7 Jun 2022 17:16:36 +0530 Subject: [PATCH 31/55] Dynamic ID added. --- lib/shopify/src/shopify_store.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index f0455db4..1d467b50 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -452,7 +452,7 @@ class ShopifyStore with ShopifyError { final WatchQueryOptions _options = WatchQueryOptions( document: gql(getMetaField), variables: { - 'ownerId': "gid://shopify/Product/6662536396859"}); + 'ownerId': "gid://shopify/Product/$id"}); final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); checkForError(result); From db1e678f37cbee8f558b146942807e2ef9fa6b04 Mon Sep 17 00:00:00 2001 From: WildForkVirat <103408411+WildForkVirat@users.noreply.github.com> Date: Tue, 7 Jun 2022 21:11:40 +0530 Subject: [PATCH 32/55] Delete allow_storefront_api_access.dart --- .../allow_storefront_api_access.dart | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 lib/graphql_operations/mutations/allow_storefront_api_access.dart diff --git a/lib/graphql_operations/mutations/allow_storefront_api_access.dart b/lib/graphql_operations/mutations/allow_storefront_api_access.dart deleted file mode 100644 index 15866556..00000000 --- a/lib/graphql_operations/mutations/allow_storefront_api_access.dart +++ /dev/null @@ -1,22 +0,0 @@ -const String allowStoreFrontApiMutation = r''' -mutation { - metafieldStorefrontVisibilityCreate( - input: { - namespace: "wildfox" - key: "country_of_origin" - ownerType: PRODUCT - } - ) { - metafieldStorefrontVisibility { - id - key - namespace - value - } - userErrors { - field - message - } - } -} -'''; \ No newline at end of file From e23e9a3276046e75646e41631fb70a25abda6de6 Mon Sep 17 00:00:00 2001 From: WildForkVirat <103408411+WildForkVirat@users.noreply.github.com> Date: Tue, 7 Jun 2022 21:13:52 +0530 Subject: [PATCH 33/55] Update get_meta_field.dart --- lib/graphql_operations/queries/get_meta_field.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index f7172f1c..ffa4f3f9 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,7 +1,7 @@ const String getMetaField = r''' -query ProductMetafields($ownerId : ID!){ - product(id: $ownerId) { - metafields(namespace: "wildfox", first: 3) { +query ProductMetafields($productId : ID!){ + product(id: $productId) { + metafields(namespace: "wildfox", first: 50) { edges { node { id @@ -15,4 +15,4 @@ query ProductMetafields($ownerId : ID!){ } } } -'''; \ No newline at end of file +'''; From 87b31fda247320026c9f34ea4416783776dda9c5 Mon Sep 17 00:00:00 2001 From: WildForkVirat <103408411+WildForkVirat@users.noreply.github.com> Date: Tue, 7 Jun 2022 21:15:25 +0530 Subject: [PATCH 34/55] Delete shopify_product.dart --- lib/shopify/src/shopify_product.dart | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 lib/shopify/src/shopify_product.dart diff --git a/lib/shopify/src/shopify_product.dart b/lib/shopify/src/shopify_product.dart deleted file mode 100644 index 242bad92..00000000 --- a/lib/shopify/src/shopify_product.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:graphql/client.dart'; -import '../../graphql_operations/mutations/allow_storefront_api_access.dart'; -import '../../mixins/src/shopfiy_error.dart'; -import '../../shopify_config.dart'; - -class ShopifyProduct with ShopifyError{ - - ShopifyProduct._(); - - static final ShopifyProduct instance = ShopifyProduct._(); - - GraphQLClient? get _graphQLClient => ShopifyConfig.graphQLClient; - - Future allowStoreFrontApi() async{ - final MutationOptions _options = MutationOptions( - document: gql(allowStoreFrontApiMutation), - ); - final QueryResult result = (await _graphQLClient!.mutate(_options)); - checkForError(result); - } -} \ No newline at end of file From a730ff1fe48035b1cd3240a6eba39f0bc3e6c7cf Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Fri, 10 Jun 2022 13:37:59 +0530 Subject: [PATCH 35/55] Last name added in customer_create.dart query. --- lib/graphql_operations/mutations/customer_create.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/graphql_operations/mutations/customer_create.dart b/lib/graphql_operations/mutations/customer_create.dart index 823fd7f4..c0b142fa 100644 --- a/lib/graphql_operations/mutations/customer_create.dart +++ b/lib/graphql_operations/mutations/customer_create.dart @@ -48,6 +48,7 @@ mutation MyMutation($firstName: String, $lastName: String, $email: String!, $pas displayName email firstName + lastName id lastIncompleteCheckout { completedAt From aef199ecf070980ed9e09f43286b31655e52cffb Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Mon, 27 Jun 2022 15:02:29 +0530 Subject: [PATCH 36/55] Get metafields count changed to 10. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index ffa4f3f9..39409fa1 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,7 +1,7 @@ const String getMetaField = r''' query ProductMetafields($productId : ID!){ product(id: $productId) { - metafields(namespace: "wildfox", first: 50) { + metafields(namespace: "wildfox", first: 10) { edges { node { id From 65de57970bd059239649b4e13faee91b18435359 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Mon, 27 Jun 2022 15:15:04 +0530 Subject: [PATCH 37/55] Minor changes. --- lib/graphql_operations/queries/get_meta_field.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 39409fa1..cf0794ce 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,15 +1,13 @@ const String getMetaField = r''' query ProductMetafields($productId : ID!){ product(id: $productId) { - metafields(namespace: "wildfox", first: 10) { + metafields(namespace: "wildfox", first: 50) { edges { node { id namespace key value - valueType - description } } } From 002a5ffc2059843874952bbcc9392b88f4c61f67 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 28 Jun 2022 16:50:15 +0530 Subject: [PATCH 38/55] ProductId changed to ownerId. --- lib/graphql_operations/queries/get_meta_field.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index cf0794ce..43c2b9d1 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,6 +1,6 @@ const String getMetaField = r''' -query ProductMetafields($productId : ID!){ - product(id: $productId) { +query ProductMetafields($ownerId : ID!){ + product(id: $ownerId) { metafields(namespace: "wildfox", first: 50) { edges { node { From 5714c7bf93a6d5d1231b5d4dcdc98ad1124fbb16 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Tue, 28 Jun 2022 17:01:03 +0530 Subject: [PATCH 39/55] Value type and description added. --- lib/graphql_operations/queries/get_meta_field.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 43c2b9d1..0520ebd7 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -8,6 +8,8 @@ query ProductMetafields($ownerId : ID!){ namespace key value + valueType + description } } } From 4581fc666eeab8f90a3f8f13be4033ecab235fd6 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 29 Jun 2022 11:26:15 +0530 Subject: [PATCH 40/55] Product variant metaField added. --- .../queries/get_meta_field.dart | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 0520ebd7..d71cc320 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -13,6 +13,36 @@ query ProductMetafields($ownerId : ID!){ } } } + variants(first: 250) { + edges { + node { + id + title + image { + altText + id + originalSrc + } + priceV2 { + amount + currencyCode + } + compareAtPriceV2 { + amount + currencyCode + } + weight + weightUnit + availableForSale + sku + requiresShipping + selectedOptions { + name + value + } + } + } + } } } '''; From 666ee2a057c1c82ef50c0406409ca399f145b26e Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Wed, 29 Jun 2022 16:05:18 +0530 Subject: [PATCH 41/55] Product variant metaField removed. --- .../queries/get_meta_field.dart | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index d71cc320..0520ebd7 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -13,36 +13,6 @@ query ProductMetafields($ownerId : ID!){ } } } - variants(first: 250) { - edges { - node { - id - title - image { - altText - id - originalSrc - } - priceV2 { - amount - currencyCode - } - compareAtPriceV2 { - amount - currencyCode - } - weight - weightUnit - availableForSale - sku - requiresShipping - selectedOptions { - name - value - } - } - } - } } } '''; From 1257c0289957ccca5d0cf637a8abcf4cdfddd66c Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 16:57:35 +0530 Subject: [PATCH 42/55] Product variant metaField query added. --- .../get_product_variant_meta_field.dart | 19 ++++++++++++++++++ lib/shopify/src/shopify_store.dart | 20 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 lib/graphql_operations/queries/get_product_variant_meta_field.dart diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart new file mode 100644 index 00000000..62813eb2 --- /dev/null +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -0,0 +1,19 @@ +const String getProductVariantMetaField = r''' +query getProductVariantMetafields($ownerId : ID!){ + productVariantsMetafields(first: 10) { + edges { + node { + metafields(first: 10) { + edges { + node { + namespace + key + value + } + } + } + } + } + } +} +'''; \ No newline at end of file diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 1d467b50..166530e1 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -23,6 +23,7 @@ import 'package:graphql/client.dart'; import '../../graphql_operations/queries/get_featured_collections.dart'; import '../../graphql_operations/queries/get_n_products.dart'; +import '../../graphql_operations/queries/get_product_variant_meta_field.dart'; import '../../graphql_operations/queries/get_products.dart'; import '../../models/src/collection/collection.dart'; import '../../shopify_config.dart'; @@ -465,4 +466,23 @@ class ShopifyStore with ShopifyError { .toList(); } + + Future> getProductVariantMetaFields( + String id, {bool deleteThisPartOfCache = false}) async { + final WatchQueryOptions _options = WatchQueryOptions( + document: gql(getProductVariantMetaField), + variables: { + 'ownerId': "gid://shopify/Product/$id"}); + final QueryResult result = + await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); + if (deleteThisPartOfCache) { + _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); + } + return (result.data!['product']['metafields']['edges'] + as List) + .map((e) => Metafield.fromGraphJson(e as Map)) + .toList(); + + } } From aff8dfdf1d31dcca84a4ef1dfd282f3008ba6936 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:06:08 +0530 Subject: [PATCH 43/55] Minor changes in query. --- .../queries/get_product_variant_meta_field.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 62813eb2..7ed1791d 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,6 +1,6 @@ const String getProductVariantMetaField = r''' -query getProductVariantMetafields($ownerId : ID!){ - productVariantsMetafields(first: 10) { +query ProductMetafields($ownerId : ID!){ + productVariants(first: 10) { edges { node { metafields(first: 10) { From d4bf7545df681b28c305373c6045b1ea4dc6ccaf Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:21:00 +0530 Subject: [PATCH 44/55] Minor changes in query. --- .../get_product_variant_meta_field.dart | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 7ed1791d..17918b81 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,13 +1,25 @@ const String getProductVariantMetaField = r''' query ProductMetafields($ownerId : ID!){ - productVariants(first: 10) { - edges { - node { - metafields(first: 10) { + product(id: $ownerId) { + metafields { + edges { + node { + id + key + namespace + value + } + } + } + variants(first: 10) { + edges + nodes { + metafields { edges { node { - namespace + id key + namespace value } } From be2dee6f9fcb1957b86ab09de323d95f909bee32 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:30:58 +0530 Subject: [PATCH 45/55] Minor changes in query. --- .../queries/get_product_variant_meta_field.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 17918b81..5c889977 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -12,15 +12,16 @@ query ProductMetafields($ownerId : ID!){ } } variants(first: 10) { - edges - nodes { + edges { + node { metafields { - edges { - node { - id - key - namespace - value + edges { + node { + id + key + namespace + value + } } } } From 26600830ed6c7553145499b47af46703ba256e52 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:38:07 +0530 Subject: [PATCH 46/55] Minor changes in query. --- .../get_product_variant_meta_field.dart | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 5c889977..89b5b45b 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,32 +1,34 @@ const String getProductVariantMetaField = r''' query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { - metafields { - edges { - node { - id - key - namespace - value + metafields(namespace: "wildfox", first: 50) { + edges { + node { + id + key + namespace + value + valueType + description + } } } - } - variants(first: 10) { - edges { - node { - metafields { - edges { - node { - id - key - namespace - value + variants(first: 10) { + edges { + node { + metafields { + edges { + node { + id + key + namespace + value + } } } } } } - } } } '''; \ No newline at end of file From 86da12e3a27aa7437a5a7306a8ac06062c5e0821 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:49:07 +0530 Subject: [PATCH 47/55] Minor changes in query. --- .../queries/get_product_variant_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 89b5b45b..44c8e31e 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,7 +1,7 @@ const String getProductVariantMetaField = r''' query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { - metafields(namespace: "wildfox", first: 50) { + metafields(namespace: "wildfox", first: 10) { edges { node { id From 18f847f743a1fbafad000cb805f07454f5780dc3 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 30 Jun 2022 17:56:26 +0530 Subject: [PATCH 48/55] Minor changes in query. --- .../queries/get_product_variant_meta_field.dart | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 44c8e31e..275921d6 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,18 +1,6 @@ const String getProductVariantMetaField = r''' query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { - metafields(namespace: "wildfox", first: 10) { - edges { - node { - id - key - namespace - value - valueType - description - } - } - } variants(first: 10) { edges { node { From 481e54529a5026509d979111abdc9312316608ff Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Fri, 1 Jul 2022 12:57:08 +0530 Subject: [PATCH 49/55] First and last added. --- .../queries/get_product_variant_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart index 275921d6..3703165b 100644 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ b/lib/graphql_operations/queries/get_product_variant_meta_field.dart @@ -1,7 +1,7 @@ const String getProductVariantMetaField = r''' query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { - variants(first: 10) { + variants(first: 10, last: 10) { edges { node { metafields { From c99322202bc02fd2083529c2d9bb7c9870f7c905 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 28 Jul 2022 10:38:24 +0530 Subject: [PATCH 50/55] product variant query changes. --- .../queries/get_metafileds_from_product.dart | 28 ++++++++++++++----- .../get_product_variant_meta_field.dart | 22 --------------- lib/shopify/src/shopify_store.dart | 19 ------------- 3 files changed, 21 insertions(+), 48 deletions(-) delete mode 100644 lib/graphql_operations/queries/get_product_variant_meta_field.dart diff --git a/lib/graphql_operations/queries/get_metafileds_from_product.dart b/lib/graphql_operations/queries/get_metafileds_from_product.dart index 3cb75f0c..c8a11bf0 100644 --- a/lib/graphql_operations/queries/get_metafileds_from_product.dart +++ b/lib/graphql_operations/queries/get_metafileds_from_product.dart @@ -1,18 +1,32 @@ const String getMetafieldsFromProductQuery = r''' query($handle: String!, $namespace: String!) { productByHandle(handle: $handle) { - metafields(first: 250, namespace: $namespace) { + products (first : 5) { edges { node { id - namespace - key - value - valueType - description + title + variants(first : 5){ + edges { + node { + id + title + metafields (first : 250, namespace: $namespace)){ + edges { + node { + id + namespace + key + value + } + } + } + } + } + } } } } } } - '''; + '''; \ No newline at end of file diff --git a/lib/graphql_operations/queries/get_product_variant_meta_field.dart b/lib/graphql_operations/queries/get_product_variant_meta_field.dart deleted file mode 100644 index 3703165b..00000000 --- a/lib/graphql_operations/queries/get_product_variant_meta_field.dart +++ /dev/null @@ -1,22 +0,0 @@ -const String getProductVariantMetaField = r''' -query ProductMetafields($ownerId : ID!){ - product(id: $ownerId) { - variants(first: 10, last: 10) { - edges { - node { - metafields { - edges { - node { - id - key - namespace - value - } - } - } - } - } - } - } -} -'''; \ No newline at end of file diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 166530e1..869fa520 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -23,7 +23,6 @@ import 'package:graphql/client.dart'; import '../../graphql_operations/queries/get_featured_collections.dart'; import '../../graphql_operations/queries/get_n_products.dart'; -import '../../graphql_operations/queries/get_product_variant_meta_field.dart'; import '../../graphql_operations/queries/get_products.dart'; import '../../models/src/collection/collection.dart'; import '../../shopify_config.dart'; @@ -467,22 +466,4 @@ class ShopifyStore with ShopifyError { } - Future> getProductVariantMetaFields( - String id, {bool deleteThisPartOfCache = false}) async { - final WatchQueryOptions _options = WatchQueryOptions( - document: gql(getProductVariantMetaField), - variables: { - 'ownerId': "gid://shopify/Product/$id"}); - final QueryResult result = - await ShopifyConfig.graphQLClient!.query(_options); - checkForError(result); - if (deleteThisPartOfCache) { - _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); - } - return (result.data!['product']['metafields']['edges'] - as List) - .map((e) => Metafield.fromGraphJson(e as Map)) - .toList(); - - } } From 52b529fbded0e04127ecfa70ed40ca36958d6be0 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 28 Jul 2022 11:09:10 +0530 Subject: [PATCH 51/55] product variant query changes in meta field. --- .../queries/get_meta_field.dart | 20 +++++++++++++ .../queries/get_metafileds_from_product.dart | 28 +++++-------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 0520ebd7..f1fb2072 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -1,6 +1,26 @@ const String getMetaField = r''' query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { + id + title + variants(first : 5){ + edges { + node { + id + title + metafields (first : 250, namespace: $namespace){ + edges { + node { + id + namespace + key + value + } + } + } + } + } + } metafields(namespace: "wildfox", first: 50) { edges { node { diff --git a/lib/graphql_operations/queries/get_metafileds_from_product.dart b/lib/graphql_operations/queries/get_metafileds_from_product.dart index c8a11bf0..3cb75f0c 100644 --- a/lib/graphql_operations/queries/get_metafileds_from_product.dart +++ b/lib/graphql_operations/queries/get_metafileds_from_product.dart @@ -1,32 +1,18 @@ const String getMetafieldsFromProductQuery = r''' query($handle: String!, $namespace: String!) { productByHandle(handle: $handle) { - products (first : 5) { + metafields(first: 250, namespace: $namespace) { edges { node { id - title - variants(first : 5){ - edges { - node { - id - title - metafields (first : 250, namespace: $namespace)){ - edges { - node { - id - namespace - key - value - } - } - } - } - } - } + namespace + key + value + valueType + description } } } } } - '''; \ No newline at end of file + '''; From dd568775681269b6c21db932b1274fd80edeadfe Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 28 Jul 2022 11:23:10 +0530 Subject: [PATCH 52/55] namespace added. --- lib/graphql_operations/queries/get_meta_field.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index f1fb2072..670b1405 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -8,7 +8,7 @@ query ProductMetafields($ownerId : ID!){ node { id title - metafields (first : 250, namespace: $namespace){ + metafields (first : 250, namespace: "wildfox"){ edges { node { id From cac1d09a51116dbc1c3fb8425b001f29e29bb48e Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 28 Jul 2022 13:26:02 +0530 Subject: [PATCH 53/55] Product variant added. --- .../queries/get_meta_field.dart | 28 +++++++++---------- lib/shopify/src/shopify_store.dart | 20 +++++++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart index 670b1405..48a4efb0 100644 --- a/lib/graphql_operations/queries/get_meta_field.dart +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -3,12 +3,24 @@ query ProductMetafields($ownerId : ID!){ product(id: $ownerId) { id title - variants(first : 5){ + metafields(namespace: "wildfox", first: 50) { + edges { + node { + id + namespace + key + value + valueType + description + } + } + } + variants(first : 50){ edges { node { id title - metafields (first : 250, namespace: "wildfox"){ + metafields (first : 50, namespace: "wildfox"){ edges { node { id @@ -21,18 +33,6 @@ query ProductMetafields($ownerId : ID!){ } } } - metafields(namespace: "wildfox", first: 50) { - edges { - node { - id - namespace - key - value - valueType - description - } - } - } } } '''; diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 869fa520..63902bd6 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -466,4 +466,24 @@ class ShopifyStore with ShopifyError { } + Future> getProductVariantMetaFields( + String id, {bool deleteThisPartOfCache = false}) async { + final WatchQueryOptions _options = WatchQueryOptions( + document: gql(getMetaField), + variables: { + 'ownerId': "gid://shopify/Product/$id"}); + final QueryResult result = + await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); + if (deleteThisPartOfCache) { + _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); + } + return (result.data!['product']['variants']['edges'][0]['node'] + as List) + .map((e) => Metafield.fromGraphJson(e as Map)) + .toList(); + + } + + } From 5ed94d94f6b5f4e3941f43cef647a6d8ea768838 Mon Sep 17 00:00:00 2001 From: Virat Contractor Date: Thu, 28 Jul 2022 16:16:01 +0530 Subject: [PATCH 54/55] Metafield changes. --- .../src/product/metafield/metafield.dart | 7 +- .../product/metafield/metafield.freezed.dart | 72 +++---------------- .../src/product/metafield/metafield.g.dart | 4 -- lib/shopify/src/shopify_store.dart | 2 +- 4 files changed, 12 insertions(+), 73 deletions(-) diff --git a/lib/models/src/product/metafield/metafield.dart b/lib/models/src/product/metafield/metafield.dart index bdd99d3f..a9e361b4 100644 --- a/lib/models/src/product/metafield/metafield.dart +++ b/lib/models/src/product/metafield/metafield.dart @@ -12,8 +12,7 @@ class Metafield with _$Metafield { required String namespace, required String key, required String value, - required String valueType, - @Default('') String? description, + }) = _Metafield; static Metafield fromGraphJson(Map json) { @@ -22,8 +21,8 @@ class Metafield with _$Metafield { namespace: (json['node'] ?? const {})['namespace'], key: (json['node'] ?? const {})['key'], value: (json['node'] ?? const {})['value'], - valueType: (json['node'] ?? const {})['valueType'], - description: (json['node'] ?? const {})['description']); + + ); } factory Metafield.fromJson(Map json) => diff --git a/lib/models/src/product/metafield/metafield.freezed.dart b/lib/models/src/product/metafield/metafield.freezed.dart index 2f15afa7..5f7980f3 100644 --- a/lib/models/src/product/metafield/metafield.freezed.dart +++ b/lib/models/src/product/metafield/metafield.freezed.dart @@ -26,16 +26,12 @@ class _$MetafieldTearOff { {required String id, required String namespace, required String key, - required String value, - required String valueType, - String? description = ''}) { + required String value}) { return _Metafield( id: id, namespace: namespace, key: key, value: value, - valueType: valueType, - description: description, ); } @@ -53,8 +49,6 @@ mixin _$Metafield { String get namespace => throw _privateConstructorUsedError; String get key => throw _privateConstructorUsedError; String get value => throw _privateConstructorUsedError; - String get valueType => throw _privateConstructorUsedError; - String? get description => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -66,13 +60,7 @@ mixin _$Metafield { abstract class $MetafieldCopyWith<$Res> { factory $MetafieldCopyWith(Metafield value, $Res Function(Metafield) then) = _$MetafieldCopyWithImpl<$Res>; - $Res call( - {String id, - String namespace, - String key, - String value, - String valueType, - String? description}); + $Res call({String id, String namespace, String key, String value}); } /// @nodoc @@ -89,8 +77,6 @@ class _$MetafieldCopyWithImpl<$Res> implements $MetafieldCopyWith<$Res> { Object? namespace = freezed, Object? key = freezed, Object? value = freezed, - Object? valueType = freezed, - Object? description = freezed, }) { return _then(_value.copyWith( id: id == freezed @@ -109,14 +95,6 @@ class _$MetafieldCopyWithImpl<$Res> implements $MetafieldCopyWith<$Res> { ? _value.value : value // ignore: cast_nullable_to_non_nullable as String, - valueType: valueType == freezed - ? _value.valueType - : valueType // ignore: cast_nullable_to_non_nullable - as String, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, )); } } @@ -127,13 +105,7 @@ abstract class _$MetafieldCopyWith<$Res> implements $MetafieldCopyWith<$Res> { _Metafield value, $Res Function(_Metafield) then) = __$MetafieldCopyWithImpl<$Res>; @override - $Res call( - {String id, - String namespace, - String key, - String value, - String valueType, - String? description}); + $Res call({String id, String namespace, String key, String value}); } /// @nodoc @@ -151,8 +123,6 @@ class __$MetafieldCopyWithImpl<$Res> extends _$MetafieldCopyWithImpl<$Res> Object? namespace = freezed, Object? key = freezed, Object? value = freezed, - Object? valueType = freezed, - Object? description = freezed, }) { return _then(_Metafield( id: id == freezed @@ -171,14 +141,6 @@ class __$MetafieldCopyWithImpl<$Res> extends _$MetafieldCopyWithImpl<$Res> ? _value.value : value // ignore: cast_nullable_to_non_nullable as String, - valueType: valueType == freezed - ? _value.valueType - : valueType // ignore: cast_nullable_to_non_nullable - as String, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, )); } } @@ -190,9 +152,7 @@ class _$_Metafield extends _Metafield { {required this.id, required this.namespace, required this.key, - required this.value, - required this.valueType, - this.description = ''}) + required this.value}) : super._(); factory _$_Metafield.fromJson(Map json) => @@ -206,15 +166,10 @@ class _$_Metafield extends _Metafield { final String key; @override final String value; - @override - final String valueType; - @JsonKey() - @override - final String? description; @override String toString() { - return 'Metafield(id: $id, namespace: $namespace, key: $key, value: $value, valueType: $valueType, description: $description)'; + return 'Metafield(id: $id, namespace: $namespace, key: $key, value: $value)'; } @override @@ -225,10 +180,7 @@ class _$_Metafield extends _Metafield { const DeepCollectionEquality().equals(other.id, id) && const DeepCollectionEquality().equals(other.namespace, namespace) && const DeepCollectionEquality().equals(other.key, key) && - const DeepCollectionEquality().equals(other.value, value) && - const DeepCollectionEquality().equals(other.valueType, valueType) && - const DeepCollectionEquality() - .equals(other.description, description)); + const DeepCollectionEquality().equals(other.value, value)); } @override @@ -237,9 +189,7 @@ class _$_Metafield extends _Metafield { const DeepCollectionEquality().hash(id), const DeepCollectionEquality().hash(namespace), const DeepCollectionEquality().hash(key), - const DeepCollectionEquality().hash(value), - const DeepCollectionEquality().hash(valueType), - const DeepCollectionEquality().hash(description)); + const DeepCollectionEquality().hash(value)); @JsonKey(ignore: true) @override @@ -257,9 +207,7 @@ abstract class _Metafield extends Metafield { {required String id, required String namespace, required String key, - required String value, - required String valueType, - String? description}) = _$_Metafield; + required String value}) = _$_Metafield; _Metafield._() : super._(); factory _Metafield.fromJson(Map json) = @@ -274,10 +222,6 @@ abstract class _Metafield extends Metafield { @override String get value; @override - String get valueType; - @override - String? get description; - @override @JsonKey(ignore: true) _$MetafieldCopyWith<_Metafield> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/models/src/product/metafield/metafield.g.dart b/lib/models/src/product/metafield/metafield.g.dart index 5528c00e..2f14b4cc 100644 --- a/lib/models/src/product/metafield/metafield.g.dart +++ b/lib/models/src/product/metafield/metafield.g.dart @@ -11,8 +11,6 @@ _$_Metafield _$$_MetafieldFromJson(Map json) => _$_Metafield( namespace: json['namespace'] as String, key: json['key'] as String, value: json['value'] as String, - valueType: json['valueType'] as String, - description: json['description'] as String? ?? '', ); Map _$$_MetafieldToJson(_$_Metafield instance) => @@ -21,6 +19,4 @@ Map _$$_MetafieldToJson(_$_Metafield instance) => 'namespace': instance.namespace, 'key': instance.key, 'value': instance.value, - 'valueType': instance.valueType, - 'description': instance.description, }; diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index 63902bd6..4f448b43 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -478,7 +478,7 @@ class ShopifyStore with ShopifyError { if (deleteThisPartOfCache) { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } - return (result.data!['product']['variants']['edges'][0]['node'] + return (result.data!['product']['variants']['edges'][0]['node']['metafields']['edges'] as List) .map((e) => Metafield.fromGraphJson(e as Map)) .toList(); From 3c78a403563213e8eb51b45a4e9e535b94c437ac Mon Sep 17 00:00:00 2001 From: tonylib Date: Tue, 30 Aug 2022 10:00:32 -0400 Subject: [PATCH 55/55] Changes to handle Orders --- .../line_item_order/line_item_order.dart | 10 +++++---- .../line_items_order/line_items_order.dart | 4 ++-- lib/models/src/order/order.dart | 2 +- lib/models/src/order/order.g.dart | 22 +++++++++---------- lib/models/src/order/orders/orders.dart | 4 ++-- lib/models/src/order/orders/orders.g.dart | 8 +++---- lib/shopify/src/shopify_checkout.dart | 4 +--- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/models/src/order/line_item_order/line_item_order.dart b/lib/models/src/order/line_item_order/line_item_order.dart index efc0fe0c..388036ac 100644 --- a/lib/models/src/order/line_item_order/line_item_order.dart +++ b/lib/models/src/order/line_item_order/line_item_order.dart @@ -27,14 +27,16 @@ class LineItemOrder with _$LineItemOrder { return LineItemOrder( currentQuantity: (json['node'] ?? const {})['currentQuantity'], discountAllocations: _getDiscountAllocationsList(json), - discountedTotalPrice: PriceV2.fromJson( - (json['node'] ?? const {})['discountedTotalPrice']), + discountedTotalPrice: PriceV2.fromJson((json['node'] ?? + const {})['discountedTotalPrice'] as Map), originalTotalPrice: PriceV2.fromJson((json['node'] ?? const {})['originalTotalPrice']), quantity: (json['node'] ?? const {})['quantity'], title: (json['node'] ?? const {})['title'], - variant: ProductVariantCheckout.fromJson( - (json['node'] ?? const {})['variant'] ?? const {})); + variant: json['node']!['variant'] == null + ? null + : ProductVariantCheckout.fromJson( + (json['node'] ?? const {})['variant'] ?? const {})); } static _getDiscountAllocationsList(Map json) { diff --git a/lib/models/src/order/line_items_order/line_items_order.dart b/lib/models/src/order/line_items_order/line_items_order.dart index 2f89320f..e646711c 100644 --- a/lib/models/src/order/line_items_order/line_items_order.dart +++ b/lib/models/src/order/line_items_order/line_items_order.dart @@ -18,8 +18,8 @@ class LineItemsOrder with _$LineItemsOrder { static _getLineItemOrderList(Map json) { List lineItemListOrder = []; - json['edges']?.forEach((lineItemOrder) => - lineItemListOrder.add(LineItemOrder.fromGraphJson(lineItemOrder))); + json['edges']?.forEach((lineItemOrder) => lineItemListOrder.add( + LineItemOrder.fromGraphJson(lineItemOrder as Map))); return lineItemListOrder; } } diff --git a/lib/models/src/order/order.dart b/lib/models/src/order/order.dart index 0b68cea5..c2cd3bc3 100644 --- a/lib/models/src/order/order.dart +++ b/lib/models/src/order/order.dart @@ -37,7 +37,7 @@ class Order with _$Order { email: (json['node'] ?? const {})['email'], currencyCode: (json['node'] ?? const {})['currencyCode'], customerUrl: (json['node'] ?? const {})['customerUrl'], - lineItems: LineItemsOrder.fromJson( + lineItems: LineItemsOrder.fromGraphJson( (json['node'] ?? const {})['lineItems'] ?? const {}), name: (json['node'] ?? const {})['name'], orderNumber: (json['node'] ?? const {})['orderNumber'], diff --git a/lib/models/src/order/order.g.dart b/lib/models/src/order/order.g.dart index 042177ac..deef1355 100644 --- a/lib/models/src/order/order.g.dart +++ b/lib/models/src/order/order.g.dart @@ -7,18 +7,18 @@ part of 'order.dart'; // ************************************************************************** _$_Order _$$_OrderFromJson(Map json) => _$_Order( - id: json['id'] as String, - email: json['email'] as String, - currencyCode: json['currencyCode'] as String, - customerUrl: json['customerUrl'] as String, - lineItems: - LineItemsOrder.fromJson(json['lineItems'] as Map), - name: json['name'] as String, - orderNumber: json['orderNumber'] as int, - processedAt: json['processedAt'] as String, + id: json['node']['id'] as String, + email: json['node']['email'] as String, + currencyCode: json['node']['currencyCode'] as String, + customerUrl: json['node']['customerUrl'] as String, + lineItems: LineItemsOrder.fromJson( + json['node']['lineItems'] as Map), + name: json['node']['name'] as String, + orderNumber: json['node']['orderNumber'] as int, + processedAt: json['node']['processedAt'] as String, shippingAddress: ShippingAddress.fromJson( - json['shippingAddress'] as Map), - statusUrl: json['statusUrl'] as String, + json['node']['shippingAddress'] as Map), + statusUrl: json['node']['statusUrl'] as String, subtotalPriceV2: PriceV2.fromJson(json['subtotalPriceV2'] as Map), totalPriceV2: diff --git a/lib/models/src/order/orders/orders.dart b/lib/models/src/order/orders/orders.dart index 0134901c..0a9fad56 100644 --- a/lib/models/src/order/orders/orders.dart +++ b/lib/models/src/order/orders/orders.dart @@ -9,13 +9,13 @@ part 'orders.g.dart'; class Orders with _$Orders { factory Orders({required List orderList, required bool hasNextPage}) = _Orders; - + factory Orders.fromJson(Map json) => _$OrdersFromJson(json); static Orders fromGraphJson(Map json) { return Orders( orderList: _getOrderList(json), - hasNextPage: (json['pageInfo'] ?? const {})['hasNextPage']); + hasNextPage: false); //(json['pageInfo'] ?? const {})['hasNextPage']); } static List _getOrderList(Map json) { diff --git a/lib/models/src/order/orders/orders.g.dart b/lib/models/src/order/orders/orders.g.dart index 36cc9fd7..f9afb7bc 100644 --- a/lib/models/src/order/orders/orders.g.dart +++ b/lib/models/src/order/orders/orders.g.dart @@ -7,10 +7,10 @@ part of 'orders.dart'; // ************************************************************************** _$_Orders _$$_OrdersFromJson(Map json) => _$_Orders( - orderList: (json['orderList'] as List) - .map((e) => Order.fromJson(e as Map)) - .toList(), - hasNextPage: json['hasNextPage'] as bool, + orderList: (json['edges'] as List) + .map((e) => Order.fromGraphJson(e as Map)) + .toList(), + hasNextPage: false //json['hasNextPage'] as bool, ); Map _$$_OrdersToJson(_$_Orders instance) => { diff --git a/lib/shopify/src/shopify_checkout.dart b/lib/shopify/src/shopify_checkout.dart index e3b7d554..45776a6e 100644 --- a/lib/shopify/src/shopify_checkout.dart +++ b/lib/shopify/src/shopify_checkout.dart @@ -133,9 +133,7 @@ class ShopifyCheckout with ShopifyError { final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); checkForError(result); - Orders orders = Orders.fromJson( - (((result.data ?? const {})['customer'] ?? const {})['orders'] ?? - const {})); + Orders orders = Orders.fromGraphJson(result.data!['customer']!['orders']!); if (deleteThisPartOfCache) { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); }