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

AutoPersistedQueries supported for mutations #2509

Merged
merged 1 commit into from Aug 11, 2020

Conversation

Toxu4
Copy link
Contributor

@Toxu4 Toxu4 commented Aug 7, 2020

No description provided.

@apollo-cla
Copy link

@Toxu4: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@martinbonnin
Copy link
Contributor

Hi! Thanks for the contribution 👍 . My only concern is that it silently enables APQs (Auto Persisted Queries) on mutations for existing users upgrading from a previous version of apollo-android. While that should work in most cases, there's a chance that some servers do not handle that or that it causes various performance issues in apps, which might be hard to debug. The probability of this happening is certainly low but I don't think that's a risk we want to take.

If you want to enable APQs for mutation, you can use ApolloClient.Builder.setAutoPersistedOperationsInterceptorFactory:

builder.setAutoPersistedOperationsInterceptorFactory(ApolloAutoPersistedOperationInterceptor.Factory())

@Toxu4
Copy link
Contributor Author

Toxu4 commented Aug 7, 2020

Hi! Thanks for the contribution 👍 . My only concern is that it silently enables APQs (Auto Persisted Queries) on mutations for existing users upgrading from a previous version of apollo-android. While that should work in most cases, there's a chance that some servers do not handle that or that it causes various performance issues in apps, which might be hard to debug. The probability of this happening is certainly low but I don't think that's a risk we want to take.

If you want to enable APQs for mutation, you can use ApolloClient.Builder.setAutoPersistedOperationsInterceptorFactory:

builder.setAutoPersistedOperationsInterceptorFactory(ApolloAutoPersistedOperationInterceptor.Factory())

Hi!
I simply implemented the same behaviour as implemented for iOS library. I think this is unwanted and unexpected behaviour - to not support APQ for mutations out of the box, without manually setting of ApolloAutoPersistedOperationInterceptor.Factory()

@DaniilSokolyuk
Copy link

I think this feature should work the same on js, ios and android clients, for js and ios it works now
apollographql/apollo-ios#1100

@martinbonnin
Copy link
Contributor

If iOS users had no issue during the transition then we can certainly take that risk.

Another option would be to add:

    public Builder enableAutoPersistedOperations(boolean persistOperations) {
      return setAutoPersistedOperationsInterceptorFactory(
                       new ApolloAutoPersistedOperationInterceptor.Factory(false, persistOperations, persistOperations)
      )
    }

That would keep the existing behaviour untouched and also be more explicit about queries vs operations. @designatednerd any thoughts?

@Toxu4
Copy link
Contributor Author

Toxu4 commented Aug 7, 2020

If iOS users had no issue during the transition then we can certainly take that risk.

Another option would be to add:

    public Builder enableAutoPersistedOperations(boolean persistOperations) {
      return setAutoPersistedOperationsInterceptorFactory(
                       new ApolloAutoPersistedOperationInterceptor.Factory(false, persistOperations, persistOperations)
      )
    }

That would keep the existing behaviour untouched and also be more explicit about queries vs operations. @designatednerd any thoughts?

I think this is a bug, so it should be fixed by changing behaviour, not by changing api.

In the long run, I would prefer the APQ to be renamed APO (AutoPersistedOperations) :)

@martinbonnin
Copy link
Contributor

Looks like enabling mutations should be fine 🤞 . I'll merge this, make a minor 2.3.0 and put a warning in the release note to make sure the change is communicated.

@martinbonnin martinbonnin merged commit d6841e8 into apollographql:master Aug 11, 2020
@martinbonnin
Copy link
Contributor

Thanks for bringing this up!

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

Successfully merging this pull request may close these issues.

None yet

4 participants