Shopify / mobile-buy-sdk-ios

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 Apple Pay or their credit card.
MIT License
452 stars 199 forks source link

address mutation fetching old address that i recently deleted #1040

Closed hamzafarooqtxlabz closed 4 years ago

hamzafarooqtxlabz commented 4 years ago

i am using this mutation for creating the address.

static func mutationForCreateAddress(address1: String, address2: String, city: String, company: String, country: String, firstName: String, lastName: String, phone: String, province: String, zip: String, token: String) -> Storefront.MutationQuery {

    let input = Storefront.MailingAddressInput.create(
        address1:  .value(address1),
        address2:  .value(address2),
        city:      .value(city),
        company:   .value(company),
        country:   .value(country),
        firstName: .value(firstName),
        lastName:  .value(lastName),
        phone:     .value(phone),
        province:  .value(province),
        zip:       .value(zip)
    )

    return Storefront.buildMutation { $0
        .customerAddressCreate(customerAccessToken: token, address: input) { $0
            .customerAddress { $0
                .id()
                .address1()
                .address2()
                .city()
                .company()
                .country()
                .firstName()
                .lastName()
                .name()
                .phone()
                .province()
                .provinceCode()
                .zip()
            }
            .customerUserErrors { $0
                .field()
                .message()
            }
        }
    }

}

the address created successfully

and i am deleting the address using this mutation

static func mutationForDeleteAddress(addressID: String, accessToken: String) -> Storefront.MutationQuery {

    return Storefront.buildMutation { $0
        .customerAddressDelete(id: GraphQL.ID(rawValue: addressID), customerAccessToken: accessToken) { $0
            .customerUserErrors { $0
                .field()
                .message()
            }
        }
    }

}

but when i refetch the address of the customer using this:

static func queryForGetCustomerAddresses(accessToken: String) -> Storefront.QueryRootQuery { return Storefront.buildQuery { $0 .customer(customerAccessToken: accessToken) { $0 .addresses(first: 50) { $0 .edges { $0 .node { $0 .id() .address1() .address2() .city() .company() .country() .firstName() .lastName() .name() .phone() .province() .provinceCode() .zip() } } } } } }

it returns me old addresses as well that i deleted recently.

but when i delete and reinstall the app, correct data is fetched. i don't know where i am going wrong

dbart01 commented 4 years ago

Check your cache policy. It sounds like you're getting back cached data. Here's the documentation that describes cache policies in the Buy SDK.

hamzafarooqtxlabz commented 4 years ago

Thank you so much. Saved my day. ;-)