Shopify / mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
MIT License
212 stars 136 forks source link

invalid global id #667

Open ghost opened 4 years ago

ghost commented 4 years ago

I can fetch first 10 products but when I use the same ID of any product to fetch details of that specific product, it throws an error of invalid global id I have made sure that product is available on app sales channel. I have tried all these options individually but got same response

Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ1NzI0MTExMzQwMjM= gid://shopify/Product/4572411134023 4572411134023

Code

Storefront.QueryRootQuery query = Storefront.query(rootQuery -> rootQuery .node(new ID("4572411134023"), 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<Storefront.QueryRoot>() {

        @Override public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) {
            Log.e("TAG", "PRO"+ response.formatErrorMessage());
            Storefront.Product product = (Storefront.Product) response.data().getNode();
            List<Storefront.Image> productImages = new ArrayList<>();
            for (final Storefront.ImageEdge imageEdge : product.getImages().getEdges()) {
                productImages.add(imageEdge.getNode());
            }
            List<Storefront.ProductVariant> productVariants = new ArrayList<>();
            for (final Storefront.ProductVariantEdge productVariantEdge : product.getVariants().getEdges()) {
                productVariants.add(productVariantEdge.getNode());

            }
            Log.e("TAG", "PRO"+ productImages.get(0).getTransformedSrc());
        }

        @Override
        public void onFailure(@NonNull GraphError error) {

        }

    });
vixdug commented 4 years ago

Can you attempt the GraphQL query in an API client such as Postman / Insomnia? The corresponding query is in the readme here: https://github.com/Shopify/mobile-buy-sdk-android/blob/99480d418f2a3fbf60e82c091a31a8de7f936713/README.md#fetch-product-details-

This will help you determine if the issue is in your code or the product. You will want to use the Storefront API ID ex. Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ1NzI0MTExMzQwMjM=