### Initializing and Executing GraphQL Queries with GraphClient in Android Buy SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Provides examples for initializing the `GraphClient` with necessary credentials and an optional `OkHttpClient`. It then demonstrates how to perform GraphQL query operations, including a full example with an asynchronous callback to handle responses and errors. ```java GraphClient.builder(this) .shopDomain(BuildConfig.SHOP_DOMAIN) .accessToken(BuildConfig.API_KEY) .httpClient(httpClient) // optional .build() ``` ```java GraphClient graphClient = ...; Storefront.QueryRootQuery query = ...; QueryGraphCall call = graphClient.queryGraph(query); ``` ```java GraphClient graphClient = ...; Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .shop(shopQuery -> shopQuery .name() ) ); QueryGraphCall call = graphClient.queryGraph(query); call.enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull GraphResponse response) { String name = response.data().getShop().getName(); } @Override public void onFailure(@NonNull GraphError error) { Log.e(TAG, "Failed to execute query", error); } }); ``` -------------------------------- ### Search Storefront Collections with Fuzzy Matching in Android SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Provides an example of querying `Storefront` collections using a `query` parameter for fuzzy matching, specifically searching for 'shoes' in various fields. ```java Storefront.query(root -> root .shop(shop -> shop .collections( arg -> arg .first(10) .query("shoes"), connection -> connection .edges(edges -> edges .node(node -> node .title() .description() ) ) ) ) ) ``` -------------------------------- ### Example GraphQL Error Response JSON Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Illustrates the structure of a typical GraphQL error response in JSON format, showing message, location, and fields. ```json { "errors": [ { "message": "Field 'Shop' doesn't exist on type 'QueryRoot'", "locations": [ { "line": 2, "column": 90 } ], "fields": ["Shop"] } ] } ``` -------------------------------- ### Basic GraphQL Mutation Execution in Java Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates the fundamental process of executing a GraphQL mutation using the GraphClient and a MutationGraphCall object in the Shopify Mobile Buy SDK for Android. This snippet shows the minimal setup required to initiate a mutation. ```Java GraphClient graphClient = ...; Storefront.MutationQuery query = ...; MutationGraphCall call = graphClient.mutateGraph(query); ``` -------------------------------- ### Query Customer Addresses (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java example shows how to retrieve a customer's associated addresses, including details like address1, city, province, and country, by limiting the number of results to 10. This operation also requires a valid access token. ```Java String accessToken = ...; Storefront.QueryRootQuery query = Storefront.query(root -> root .customer(accessToken, customer -> customer .addresses(arg -> arg.first(10), connection -> connection .edges(edge -> edge .node(node -> node .address1() .address2() .city() .province() .country() ) ) ) ) ); ``` -------------------------------- ### Prepare Customer Update Input with Phone Number (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java example demonstrates how to create a `Storefront.CustomerUpdateInput` object to update a customer's phone number. It uses `Input.value()` to correctly pass the new phone number, distinguishing it from `null` or undefined values. ```Java Storefront.CustomerUpdateInput input = new Storefront.CustomerUpdateInput() .setPhone(Input.value("1-123-456-7890")); ``` -------------------------------- ### Customer Password Reset Mutation with Error Handling in Java Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Provides a comprehensive example of performing a customer password reset mutation. It illustrates how to construct the mutation input, build a complex GraphQL query including nested fields and user error retrieval, execute the mutation asynchronously, and process both successful responses and specific user-facing errors. ```Java GraphClient graphClient = ...; Storefront.CustomerResetInput input = new Storefront.CustomerResetInput("c29tZSB0b2tlbiB2YWx1ZQ", "abc123"); Storefront.MutationQuery query = Storefront.mutation(rootQuery -> rootQuery .customerReset(new ID("YSBjdXN0b21lciBpZA"), input, payloadQuery -> payloadQuery .customer(customerQuery -> customerQuery .firstName() .lastName() ) .userErrors(userErrorQuery -> userErrorQuery .field() .message() ) ) ); MutationGraphCall call = graphClient.mutateGraph(query); call.enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull final GraphResponse response) { if (response.data().getCustomerReset().getUserErrors().isEmpty()) { String firstName = response.data().getCustomerReset().getCustomer().getFirstName(); String lastName = response.data().getCustomerReset().getCustomer().getLastName(); } else { Log.e(TAG, "Failed to reset customer"); } } @Override public void onFailure(@NonNull final GraphError error) { Log.e(TAG, "Failed to execute query", error); } }); ``` -------------------------------- ### Configuring GraphQL Call Retries with RetryHandler in Java Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to implement retry logic for GraphQL calls using the RetryHandler. This example shows how to set a fixed delay, limit the maximum number of retries, and define a custom condition for when a retry should occur based on the response data, such as checking for an empty shop name. ```Java GraphClient graphClient = ...; Storefront.QueryRootQuery shopNameQuery = ...; QueryGraphCall call = graphClient.queryGraph(shopNameQuery); call.enqueue(new GraphCall.Callback() { @Override public void onResponse(GraphResponse response) { ... } @Override public void onFailure(GraphError error) { ... } }, null, RetryHandler.delay(1, TimeUnit.SECONDS) .maxCount(5) .whenResponse(response -> response.data().getShop().getName().equals("Empty")) .build()); ``` -------------------------------- ### Generated GraphQL Query for Shop Name Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This is the actual GraphQL query string that is generated by the Mobile Buy SDK from the Java code examples. It shows the structure of the GraphQL request to retrieve the shop's name. ```GraphQL query { shop { name } } ``` -------------------------------- ### Query Customer Basic Information (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java snippet demonstrates how to fetch a customer's first name, last name, and email using a `Storefront.QueryRootQuery` and a valid access token. Customer queries require authentication. ```Java String accessToken = ...; Storefront.QueryRootQuery query = Storefront.query(root -> root .customer(accessToken, customer -> customer .firstName() .lastName() .email() ) ); ``` -------------------------------- ### Create Customer Account with Shopify Buy SDK (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet demonstrates how to create a new customer account using the Shopify Buy SDK. It constructs a `CustomerCreateInput` with basic customer information and then builds a `MutationQuery` to perform the `customerCreate` operation, requesting the new customer's ID, email, first name, and last name, along with any potential user errors. ```java Storefront.CustomerCreateInput input = new Storefront.CustomerCreateInput("john.smith@gmail.com", "123456") .setFirstName(Input.value("John")) .setLastName(Input.value("Smith")) .setAcceptsMarketing(Input.value(true)) .setPhone(Input.value("1-123-456-7890")); Storefront.MutationQuery mutationQuery = Storefront.mutation(mutation -> mutation .customerCreate(input, query -> query .customer(customer -> customer .id() .email() .firstName() .lastName() ) .userErrors(userError -> userError .field() .message() ) ) ); ``` -------------------------------- ### Fetch Collections and Products using Shopify Buy SDK with GraphQL Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This snippet demonstrates how to efficiently fetch collections and their associated products using the Shopify Mobile Buy SDK for Android, leveraging GraphQL to avoid the N+1 problem. It includes both the Java SDK client-side code for constructing and executing the query, and the underlying GraphQL query structure. ```java GraphClient client = ...; ... Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .shop(shopQuery -> shopQuery .collections(arg -> arg.first(10), collectionConnectionQuery -> collectionConnectionQuery .edges(collectionEdgeQuery -> collectionEdgeQuery .node(collectionQuery -> collectionQuery .title() .products(arg -> arg.first(10), productConnectionQuery -> productConnectionQuery .edges(productEdgeQuery -> productEdgeQuery .node(productQuery -> productQuery .title() .productType() .description() ) ) ) ) ) ) ) ); client.queryGraph(query).enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull GraphResponse response) { List collections = new ArrayList<>(); for (Storefront.CollectionEdge collectionEdge : response.data().getShop().getCollections().getEdges()) { collections.add(collectionEdge.getNode()); List products = new ArrayList<>(); for (Storefront.ProductEdge productEdge : collectionEdge.getNode().getProducts().getEdges()) { products.add(productEdge.getNode()); } } } ... }); ``` ```graphql { shop { collections(first: 10) { edges { node { id title products(first: 10) { edges { node { id title productType description } } } } } } } } ``` -------------------------------- ### Log In Customer and Obtain Access Token with Shopify Buy SDK (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet shows how to log in an existing customer using their email and password. It creates a `CustomerAccessTokenCreateInput` and then constructs a `MutationQuery` to execute the `customerAccessTokenCreate` mutation, retrieving the generated access token and its expiration date, along with any user errors. ```java Storefront.CustomerAccessTokenCreateInput input = new Storefront.CustomerAccessTokenCreateInput("john.smith@gmail.com", "123456"); Storefront.MutationQuery mutationQuery = Storefront.mutation(mutation -> mutation .customerAccessTokenCreate(input, query -> query .customerAccessToken(customerAccessToken -> customerAccessToken .accessToken() .expiresAt() ) .userErrors(userError -> userError .field() .message() ) ) ); ``` -------------------------------- ### Fetch Shop Metadata using Android Shopify SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to fetch essential shop metadata, including name, currency code, and refund policy details, using the Shopify Mobile Buy SDK for Android. This involves constructing a `QueryRootQuery` and enqueuing a graph call. ```Java GraphClient client = ...; ... Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .shop(shopQuery -> shopQuery .name() .currencyCode() .refundPolicy(refundPolicyQuery -> refundPolicyQuery .title() .url() ) ) ); client.queryGraph(query).enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull GraphResponse response) { String name = response.data().getShop().getName(); String currencyCode = response.data().getShop().getCurrencyCode().toString(); String refundPolicyUrl = response.data().getShop().getRefundPolicy().getUrl(); } ... }); ``` -------------------------------- ### Fetch Detailed Product Information Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Illustrates how to fetch comprehensive details for a specific product, including its title, description, images, and variants, using a single query with the Shopify Mobile Buy SDK for Android, along with its corresponding GraphQL query. It constructs a GraphQL query to retrieve product data and processes the "onResponse" callback to extract image and variant lists. ```Java GraphClient client = ...; Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .node(new ID("9Qcm9kdWN0LzMzMj"), nodeQuery -> nodeQuery .onProduct(productQuery -> productQuery .title() .description() .images(arg -> arg.first(10), imageConnectionQuery -> imageConnectionQuery .edges(imageEdgeQuery -> imageEdgeQuery .node(imageQuery -> imageQuery .src() ) ) ) .variants(arg -> arg.first(10), variantConnectionQuery -> variantConnectionQuery .edges(variantEdgeQuery -> variantEdgeQuery .node(productVariantQuery -> productVariantQuery .price() .title() .available() ) ) ) ) ) ); client.queryGraph(query).enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull GraphResponse response) { Storefront.Product product = (Storefront.Product) response.data().getNode(); List productImages = new ArrayList<>(); for (final Storefront.ImageEdge imageEdge : product.getImages().getEdges()) { productImages.add(imageEdge.getNode()); } List productVariants = new ArrayList<>(); for (final Storefront.ProductVariantEdge productVariantEdge : product.getVariants().getEdges()) { productVariants.add(productVariantEdge.getNode()); } } ... }); ``` ```GraphQL { node(id: "9Qcm9kdWN0LzMzMj") { ... on Product { id title description images(first: 10) { edges { node { id src } } } variants(first: 10) { edges { node { id price title available } } } } } } ``` -------------------------------- ### Query Customer Order History (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java snippet illustrates how to fetch a customer's order history, including order number and total price, by querying the first 10 orders. This query is authenticated and requires an access token. ```Java String accessToken = ...; Storefront.QueryRootQuery query = Storefront.query(root -> root .customer(accessToken, customer -> customer .orders(arg -> arg.first(10), connection -> connection .edges(edge -> edge .node(node -> node .orderNumber() .totalPrice() ) ) ) ) ); ``` -------------------------------- ### Create Customer Address with Shopify Buy SDK (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet demonstrates how to create a new mailing address for a customer. It requires an existing customer access token for authentication. The snippet constructs a `MailingAddressInput` with the address details and then builds a `MutationQuery` to perform the `customerAddressCreate` operation, requesting the created address's details and any potential user errors. ```java String accessToken = ...; Storefront.MailingAddressInput input = new Storefront.MailingAddressInput() .setAddress1(Input.value("80 Spadina Ave.")) .setAddress2(Input.value("Suite 400")) .setCity(Input.value("Toronto")) .setCountry(Input.value("Canada")) .setFirstName(Input.value("John")) .setLastName(Input.value("Smith")) .setPhone(Input.value("1-123-456-7890")) .setProvince(Input.value("ON")) .setZip(Input.value("M5V 2J4")); Storefront.MutationQuery mutationQuery = Storefront.mutation(mutation -> mutation .customerAddressCreate(accessToken, input, query -> query .customerAddress(customerAddress -> customerAddress .address1() .address2() ) .userErrors(userError -> userError .field() .message() ) ) ); ``` -------------------------------- ### APIDOC: GraphCall.enqueue Method Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md API documentation for the `enqueue` method, available on both `QueryGraphCall` and `MutationGraphCall`. This method executes the GraphQL call asynchronously and allows for optional retry handling. ```APIDOC GraphCall: enqueue(callback: GraphCall.Callback, retryHandler: RetryHandler = null) ``` -------------------------------- ### APIDOC: RetryHandler Class and Factory Methods Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md API documentation for the `RetryHandler` class, which encapsulates retry state and customization parameters for GraphQL calls. It details the factory methods for creating handlers with delay or exponential backoff, and methods for defining retry conditions and maximum retry counts. ```APIDOC RetryHandler: delay(delay: long, timeUnit: TimeUnit): RetryHandlerBuilder exponentialBackoff(delay: long, timeUnit: TimeUnit, multiplier: float): RetryHandlerBuilder whenResponse(condition: Condition>): RetryHandlerBuilder whenError(condition: Condition): RetryHandlerBuilder maxCount(count: int): RetryHandlerBuilder build(): RetryHandler ``` -------------------------------- ### Build GraphQL Query for Shop Name using Lambdas (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet shows a more concise way to build the same GraphQL query for fetching the shop's name, leveraging Java 8 lambda expressions. This approach reduces boilerplate compared to anonymous classes. ```Java QueryRootQuery query = Storefront.query(rootQueryBuilder -> rootQueryBuilder .shop(shopQueryBuilder -> shopQueryBuilder .name() ) ) ``` -------------------------------- ### Supported Comparison Operators for Shopify SDK Queries Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Lists the comparison operators supported by the Shopify Mobile Buy SDK for constructing search queries. These operators allow for filtering based on equality, less than, greater than, less than or equal to, and greater than or equal to conditions. ```APIDOC : equal to :< less than :> greater than :<= less than or equal to :>= greater than or equal to ``` -------------------------------- ### Add Mobile Buy SDK Dependency (Gradle) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This snippet shows how to include the Mobile Buy SDK as a dependency in an Android project using Gradle. It specifies the 'implementation' configuration for the 'buy3' artifact from 'com.shopify.mobilebuysdk'. ```Gradle implementation("com.shopify.mobilebuysdk:buy3:2025.4.0") ``` -------------------------------- ### APIDOC: GraphClient.mutateGraph Method Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md API documentation for the `mutateGraph` method of the `GraphClient` class. This method is used to initiate a GraphQL mutation operation. ```APIDOC GraphClient: mutateGraph(query: Storefront.MutationQuery): MutationGraphCall ``` -------------------------------- ### Add Mobile Buy SDK Dependency (Maven) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This snippet demonstrates how to declare the Mobile Buy SDK as a dependency in a Maven project's 'pom.xml' file. It includes the 'groupId', 'artifactId', and 'version' for the 'buy3' library. ```Maven com.shopify.mobilebuysdk buy3 2025.4.0 ``` -------------------------------- ### GraphQL Query for Shop Metadata Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Provides the corresponding GraphQL query structure for fetching shop metadata, including name, currency code, and refund policy details, which is used by the Shopify Mobile Buy SDK. ```GraphQL query { shop { name currencyCode refundPolicy { title url } } } ``` -------------------------------- ### Search Storefront Collections with Exact Field Matching in Android SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to perform an exact match search on a specific field within `Storefront` collections, using the `field:search_term` format (e.g., `collection_type:runners`). ```java .collections(arg -> arg.query("collection_type:runners"), ... ``` -------------------------------- ### Initiate Customer Password Reset with Shopify Buy SDK (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet illustrates how to initiate a password reset for a customer. It calls the `customerRecover` mutation with the customer's email address. The SDK will then send an email with instructions to the customer. The query also includes a request for `userErrors` to handle any issues with the input. ```java Storefront.MutationQuery mutationQuery = Storefront.mutation(mutation -> mutation .customerRecover("john.smith@gmail.com", query -> query .userErrors(userError -> userError .field() .message() ) ) ); ``` -------------------------------- ### Paginate Products in a Collection Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to paginate through products within a specific collection using the Shopify Mobile Buy SDK for Android, including the corresponding GraphQL query. It shows how to construct a GraphQL query using the SDK's fluent API to fetch a limited number of products, retrieve the "pageInfo" for "hasNextPage" status, and extract the "cursor" for subsequent pagination requests. The "onResponse" callback processes the fetched collection data. ```Java GraphClient client = ...; ... Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .node(new ID("IjoxNDg4MTc3MzEsImxhc3R"), nodeQuery -> nodeQuery .onCollection(collectionQuery -> collectionQuery .products( args -> args .first(10) .after(productPageCursor), productConnectionQuery -> productConnectionQuery .pageInfo(pageInfoQuery -> pageInfoQuery .hasNextPage() ) .edges(productEdgeQuery -> productEdgeQuery .cursor() .node(productQuery -> productQuery .title() .productType() .description() ) ) ) ) ) ); client.queryGraph(query).enqueue(new GraphCall.Callback() { @Override public void onResponse(@NonNull GraphResponse response) { Storefront.Collection collection = (Storefront.Collection) response.data().getNode(); boolean hasNextProductPage = collection.getProducts().getPageInfo().getHasNextPage(); List products = new ArrayList<>(); for (Storefront.ProductEdge productEdge : collection.getProducts().getEdges()) { String productPageCursor = productEdge.getCursor(); products.add(productEdge.getNode()); } } ... }); ``` ```GraphQL query { node(id: "IjoxNDg4MTc3MzEsImxhc3R") { ... on Collection { products(first: 10, after: "sdWUiOiIxNDg4MTc3M") { pageInfo { hasNextPage } edges { cursor node { id title productType description } } } } } } ``` -------------------------------- ### Combine Search Terms with Boolean Operators in Android Shopify SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Illustrates the use of boolean operators (AND, OR) to construct complex search queries in the Shopify Mobile Buy SDK for Android. This enables combining multiple search criteria for products based on tags and product types. ```Java .products(arg -> arg.query("tag:blue AND product_type:sneaker"), ... ``` ```Java .products(arg -> arg.query("(tag:blue AND product_type:sneaker) OR tag:red"), ... ``` -------------------------------- ### Build GraphQL Query for Shop Name (Java - Anonymous Class) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java code snippet demonstrates how to construct a GraphQL query using the Mobile Buy SDK to fetch the shop's name. It uses anonymous class implementations for 'QueryRootQueryDefinition' and 'ShopQueryDefinition' to define the query structure. ```Java QueryRootQuery query = Storefront.query(new Storefront.QueryRootQueryDefinition() { @Override public void define(final Storefront.QueryRootQuery rootQueryBuilder) { rootQueryBuilder.shop(new Storefront.ShopQueryDefinition() { @Override public void define(final Storefront.ShopQuery shopQueryBuilder) { shopQueryBuilder.name(); } }); } }) ``` -------------------------------- ### Querying and Casting GraphQL Node Types in Android Buy SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Illustrates how to query for GraphQL `Node` types using their `id` and subsequently cast them to their specific `Storefront` types. Emphasizes the necessity of correct type casting to prevent runtime exceptions. ```java ID id = new ID("NkZmFzZGZhc"); Storefront.query(rootQueryBuilder -> rootQueryBuilder .node(id, nodeQuery -> nodeQuery .onProduct(productQuery -> productQuery .title() ... ) ) ); ``` ```java Storefront.QueryRoot response = ...; String title = ((Storefront.Product)response.getNode()).getTitle(); ``` -------------------------------- ### Handle GraphQL `GraphResponse` Errors in Android SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to check for and format errors within a `GraphResponse` object after a GraphQL query, emphasizing that `errors` and `data` are not mutually exclusive and errors are for debug purposes. ```java GraphClient graphClient = ...; QueryRootQuery query = Storefront.query(rootQueryBuilder -> rootQueryBuilder .shop(shopQueryBuilder -> shopQueryBuilder .name() ) ); QueryGraphCall call = graphClient.queryGraph(query); call.enqueue(new GraphCall.Callback() { @Override public void onResponse(GraphResponse response) { if (response.hasErrors()) { String errorMessage = response.formatErrorMessage(); } } @Override public void onFailure(GraphError error) { } }); ``` -------------------------------- ### Check for Null or Empty Values with Exists Operator in Android Shopify SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Explains how to use the special `*` operator with negation to find products that lack specific fields, such as products without any tags, in the Shopify Mobile Buy SDK for Android. ```Java .products(arg -> arg.query("-tag:*"), ... ``` -------------------------------- ### Using GraphQL Aliases for Multiple Fields in Android Buy SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Shows how to use GraphQL aliases to query multiple fields with the same name at the same nesting level, ensuring unique field names in the query. It also demonstrates how to access these aliased nodes from the response. ```java Storefront.query(rootQueryBuilder -> rootQueryBuilder .node(new ID("NkZmFzZGZhc"), nodeQuery -> nodeQuery .onCollection(collectionQuery -> collectionQuery .withAlias("collection") .title() .description() ... ) ) .node(new ID("GZhc2Rm"), nodeQuery -> nodeQuery .onProduct(productQuery -> productQuery .withAlias("product") .title() .description() ... ) ) ); ``` ```java Storefront.QueryRoot response = ...; Storefront.Collection collection = (Storefront.Collection) response.withAlias("collection").getNode(); Storefront.Product product = (Storefront.Product) response.withAlias("product").getNode(); ``` -------------------------------- ### GraphQL Mutation for Customer Phone Update Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This GraphQL mutation shows the underlying structure for updating a customer's phone number. It corresponds to the Java SDK's `Storefront.CustomerUpdateInput` and demonstrates how the phone field is set. ```GraphQL mutation { customerUpdate( customer: { phone: "+16471234567" } customerAccessToken: "..." ) { customer { phone } } } ``` -------------------------------- ### Accessing GraphQL Response Data in Android Buy SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates the correct and incorrect ways to access data from GraphQL responses using the Shopify Mobile Buy SDK for Android. It highlights the importance of using typed properties over direct `AbstractResponse` access to ensure type safety and avoid runtime errors. ```java // The right way Storefront.QueryRoot response = ...; String name = response.getShop().getName(); ``` ```java // The wrong way (never do this) AbstractResponse response = ...; AbstractResponse shop = (AbstractResponse) response.get("shop"); String name = (String) shop.get("name"); ``` -------------------------------- ### APIDOC: GraphQL Error Types Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md API documentation explaining the two distinct types of errors encountered in GraphQL responses within the SDK: `Error` (GraphQL query errors) and `GraphError` (critical execution/processing errors). It clarifies their purpose and typical usage. ```APIDOC Error: - Represents errors inside GraphResponse related to GraphQL query itself. - For debugging purposes only. GraphError: - Represents critical errors related to GraphQL query execution and processing response. ``` -------------------------------- ### Use Comparison Operators for Date-Based Searches in Android Shopify SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Shows how to use comparison operators (e.g., :>) for non-exact matches, specifically for filtering products updated after a certain date in the Shopify Mobile Buy SDK for Android. The date string must be enclosed in escaped quotes. ```Java .products(arg -> arg.query("updated_at:>\"2017-05-29T00:00:00Z\""), ... ``` -------------------------------- ### Handle Specific `GraphError` Types in Android SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Shows how to differentiate and handle various `GraphError` subclasses (e.g., `GraphCallCanceledError`, `GraphHttpError`, `GraphNetworkError`, `GraphParseError`) within the `onFailure` callback of a `GraphCall`. ```java GraphClient graphClient = ...; QueryRootQuery query = ...; QueryGraphCall call = graphClient.queryGraph(query); call.enqueue(new GraphCall.Callback() { @Override public void onResponse(GraphResponse response) { ... } @Override public void onFailure(GraphError error) { if (error instanceof GraphCallCanceledError) { Log.e(TAG, "Call has been canceled", error); } else if (error instanceof GraphHttpError) { Log.e(TAG, "Http request failed: " + ((GraphHttpError) error).formatMessage(), error); } else if (error instanceof GraphNetworkError) { Log.e(TAG, "Network is not available", error); } else if (error instanceof GraphParseError) { // in most cases should never happen Log.e(TAG, "Failed to parse GraphQL response", error); } else { Log.e(TAG, "Failed to execute GraphQL request", error); } } }); ``` -------------------------------- ### Prepare Customer Update Input to Remove Phone Number (Java) Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This Java snippet illustrates how to clear a customer's phone number by explicitly setting it to `null` using `Input.value(null)` within a `Storefront.CustomerUpdateInput` object. This signals the intention to remove the field. ```Java Storefront.CustomerUpdateInput input = new Storefront.CustomerUpdateInput() .setPhone(Input.value(null)); ``` -------------------------------- ### GraphQL Mutation to Remove Customer Phone Number Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md This GraphQL mutation demonstrates how to set a customer's phone number to `null`, effectively removing it from their profile. This is the GraphQL equivalent of using `Input.value(null)` in the Java SDK. ```GraphQL mutation { customerUpdate(customer: { phone: null }, customerAccessToken: "...") { customer { phone } } } ``` -------------------------------- ### Negate Search Fields in Android Shopify SDK Source: https://github.com/shopify/mobile-buy-sdk-android/blob/main/README.md Demonstrates how to negate a search field in the Shopify Mobile Buy SDK for Android by prepending a hyphen to the field name. This allows filtering out specific values, such as collections not of a certain type. ```Java .collections(arg -> arg.query("-collection_type:runners"), ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.