Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutomaticPersistedQueryInterceptor now failing in 0.51.1 #2204

Closed
kylebrowning opened this issue Mar 17, 2022 · 9 comments
Closed

AutomaticPersistedQueryInterceptor now failing in 0.51.1 #2204

kylebrowning opened this issue Mar 17, 2022 · 9 comments

Comments

@kylebrowning
Copy link

kylebrowning commented Mar 17, 2022

Bug report

I recently was attempting to update our app from Apollo .49.1 to .51.1 but our persisted queries are now failing

Apollo.AutomaticPersistedQueryInterceptor.APQError.persistedQueryRetryFailed(operationName: 

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 0.51.1
  • Xcode version: Xcode 13.3
  • Swift version: Swift 5.6
  • Package manager:
@kylebrowning
Copy link
Author

kylebrowning commented Mar 17, 2022

Unless im mistaken, this broke it, downgrading to 0.51.0 works.

@Narayane
Copy link

Narayane commented Mar 18, 2022

I have the same problem. It is ok on 0.51.0 but broken on 0.51.1

10:46:10.329 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():64 - request method: POST) - https://myserver.com/graphql
10:46:10.329 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():67 - request headers: ["X-APOLLO-OPERATION-NAME": "UpdatePreferenceStartSms", "apollographql-client-version": "2.22.1-22210", ..., "Content-Type": "application/json", "X-APOLLO-OPERATION-ID": "b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d"]
10:46:10.330 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():71 - request body: ["variables": {
    input =     {
        startSmsTextHeader = Test;
    };
}, "extensions": {
    persistedQuery =     {
        sha256Hash = b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d;
        version = 1;
    };
}, "operationName": UpdatePreferenceStartSms, "id": b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d]
10:46:10.435 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():156 - response code: 200
10:46:10.436 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():157 - response headers: [AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("x-amz-cf-pop"): MRS52-C1, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("x-amz-cf-id"): T0PT3fKx2J95a4pzGjmjkehDFFrLQPK7wmCNGFW9UncdzQ6f49JMqg==, AnyHashable("Vary"): Origin, AnyHashable("Date"): Fri, 18 Mar 2022 09:46:10 GMT, AnyHashable("Content-Length"): 100, AnyHashable("Strict-Transport-Security"): max-age=864000; includeSubDomains, AnyHashable("Cache-Control"): private, no-cache, must-revalidate, AnyHashable("Via"): 1.1 6539a76bb06cb86ff6a4a036edfec006.cloudfront.net (CloudFront), AnyHashable("x-cache"): Miss from cloudfront, AnyHashable("Etag"): W/"64-pCNUOD6DZiPor9gRPcTPDcQA2zU"]
10:46:10.437 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():161 - response body: ["errors": <__NSSingleObjectArrayI 0x28356cef0>(
{
    extensions =     {
        code = "PERSISTED_QUERY_NOT_FOUND";
    };
    message = PersistedQueryNotFound;
}
)
]
10:46:10.443 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():64 - request method: POST) - https://myserver.com/graphql
10:46:10.445 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():67 - request headers: [..., "apollographql-client-version": "2.22.1-22210", "X-APOLLO-OPERATION-NAME": "UpdatePreferenceStartSms", "Content-Type": "application/json", "Date": "2022-03-18T09:46:10.437Z", "X-APOLLO-OPERATION-TYPE": "mutation", "X-APOLLO-OPERATION-ID": "b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d"]
10:46:10.448 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():71 - request body: ["variables": {
    input =     {
        startSmsTextHeader = Test;
    };
}, "operationName": UpdatePreferenceStartSms, "id": b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d, "extensions": {
    persistedQuery =     {
        sha256Hash = b9b5788e0b76faff77d78eddc4b4253339bc64df0451d3affce08b24b758b38d;
        version = 1;
    };
}]
10:46:10.547 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():156 - response code: 200
10:46:10.549 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():157 - response headers: [AnyHashable("Via"): 1.1 6539a76bb06cb86ff6a4a036edfec006.cloudfront.net (CloudFront), AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("Date"): Fri, 18 Mar 2022 09:46:10 GMT, AnyHashable("Content-Length"): 100, AnyHashable("Strict-Transport-Security"): max-age=864000; includeSubDomains, AnyHashable("x-amz-cf-id"): -k4tO35qMV98seu2OwLcscpdr5-yxB3MjQDbYSMcuPZcsW5O_CadMQ==, AnyHashable("x-amz-cf-pop"): MRS52-C1, AnyHashable("Vary"): Origin, AnyHashable("Cache-Control"): private, no-cache, must-revalidate, AnyHashable("Etag"): W/"64-pCNUOD6DZiPor9gRPcTPDcQA2zU", AnyHashable("x-cache"): Miss from cloudfront]
10:46:10.550 💜 VERBOSE LRNetworkFetchInterceptor.interceptAsync():161 - response body: ["errors": <__NSSingleObjectArrayI 0x28356a810>(
{
    extensions =     {
        code = "PERSISTED_QUERY_NOT_FOUND";
    };
    message = PersistedQueryNotFound;
}
)
]
10:46:10.560 ❤️ ERROR Apollo+Rx.perform():153 - Persisted query retry failed for operation "UpdatePreferenceStartSms".

My custom interceptor provider

struct LRNetworkInterceptorProvider: InterceptorProvider {
    
    // These properties will remain the same throughout the life of the `InterceptorProvider`, even though they will be handed to different interceptors.
    private let store: ApolloStore
    private let client: URLSessionClient
    
    init(store: ApolloStore, client: URLSessionClient) {
        self.store = store
        self.client = client
    }
    
    func interceptors<Operation: GraphQLOperation>(for operation: Operation) -> [ApolloInterceptor] {
        return [
            MaxRetryInterceptor(),
            CacheReadInterceptor(store: self.store),
            LRNetworkFetchInterceptor(client: self.client),
            ResponseCodeInterceptor(),
            JSONResponseParsingInterceptor(cacheKeyForObject: self.store.cacheKeyForObject),
            AutomaticPersistedQueryInterceptor(),
            CacheWriteInterceptor(store: self.store),
        ]
    }
}

@kylebrowning
Copy link
Author

My guess is the lazy var can't be a lazy as it will be stored and not regenerated.

@calvincestari
Copy link
Member

Thanks for reporting this @kylebrowning, I'll be taking a look at it this morning.

@AnthonyMDev
Copy link
Contributor

@kylebrowning We've got a potential fix in the branch apq-jsonrequest-fix. Would you mind pulling that branch and testing that the fix works for you. If it does, we will push a patch version ASAP!

@kylebrowning
Copy link
Author

Sure thing, trying now.

@kylebrowning
Copy link
Author

@AnthonyMDev Appears to be working!

@AnthonyMDev
Copy link
Contributor

Awesome, I'll start preparing a patch release now!

@AnthonyMDev AnthonyMDev changed the title AutomaticPersistedQueryInterceptor now failing in .51.1 AutomaticPersistedQueryInterceptor now failing in 0.51.1 Mar 18, 2022
@AnthonyMDev
Copy link
Contributor

0.51.2 Is now released! Thanks for bringing this to our attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants