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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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 150a84efddffce55807a17e7be430ee213aac750 Mon Sep 17 00:00:00 2001 From: Devin Ellis Date: Thu, 30 Jun 2022 12:54:09 -0400 Subject: [PATCH 36/37] - For testing --- lib/shopify/src/shopify_customer.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shopify/src/shopify_customer.dart b/lib/shopify/src/shopify_customer.dart index 21522c68..1c0ca067 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -95,7 +95,7 @@ class ShopifyCustomer with ShopifyError { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } } - Future getCustomerMetaFields(String? customerAccessToken) async{ + Future getCustomerMetaFields(String? customerAccessToken) async{ // call query to get customer metafields /*final MutationOptions _options = MutationOptions( document: gql(getCustomerQuery), @@ -109,7 +109,7 @@ class ShopifyCustomer with ShopifyError { final QueryResult result = (await _graphQLClient!.query(_getCustomer)); checkForError(result); - return Metafield.fromJson(result.data!['customer']['metafields']); + return result.data; } /// Creates a address for the customer to which [customerAccessToken] belongs to. Future
customerAddressCreate( From 2b10745c7f7233794c506cdbe2e44608298df99e Mon Sep 17 00:00:00 2001 From: Devin Ellis Date: Fri, 1 Jul 2022 10:08:16 -0400 Subject: [PATCH 37/37] - Still working --- 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 1c0ca067..29394fc7 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -109,7 +109,7 @@ class ShopifyCustomer with ShopifyError { final QueryResult result = (await _graphQLClient!.query(_getCustomer)); checkForError(result); - return result.data; + return result.data!['customer']['tags']; } /// Creates a address for the customer to which [customerAccessToken] belongs to. Future
customerAddressCreate(