AniTrend / retrofit-graphql

Retrofit converter which uses annotations to inject .graphql query or mutation files into a request body, along with any variables.
https://anitrend.github.io/retrofit-graphql/
Apache License 2.0
108 stars 19 forks source link

Enable ProGuards Library not working #18

Closed Brajendra closed 5 years ago

Brajendra commented 5 years ago

Have you defined progaurd rules for query for me name got change after enable progaurd, and i am not getting expected reslt.

Actual Query in Without Progaurd {"extensions":{},"operationName":"feed","query":"query feed($limit: Int!, $fetchFrom: Long, $eventTypes: String, $profile: String, $group: Int) { feed(limit: $limit, fetchFrom: $fetchFrom, eventTypes: $eventTypes, profile: $profile, group: $group) { fetchFrom feed { type meta { type id body ref rating group { ...GroupFragment } image { ...ImageFragment } shares eventId profile { ...ProfileFragment } comments { id } createdAt editionId favorites isPrivate editorRawData hasUserFavorited previewImage{ ...ImageFragment } previewText views articleId readingTime scoop{ ...ScoopFragment } source { type meta { title type body ref createdAt updatedAt editionId edition { ...EditionFragment } profile { ...ProfileFragment } previewImage{ ...ImageFragment } previewText views articleId readingTime scoop{ ...ScoopFragment } } } edition { ...EditionFragment } isUserFollowingBook defaultCollection } } }}\n\nfragment ImageFragment on Image { baseUrl key}\n\nfragment GroupFragment on Group { id name avatar { ...ImageFragment } status}\n\nfragment ProfileFragment on Profile { avatar { ...ImageFragment } username displayName isFollowing }\n\nfragment ScoopFragment on Scoop { author title url urlToImage description source{ name } tags{ name slug }}\n\nfragment CoverFragment on EditionCover{ baseUrl key}\n\nfragment EditionFragment on Edition { title id description rating { edition average id count } type cover { ...CoverFragment } authors slug ISBN13 ISBNType createdAt}","variables":{"limit":10}}

Actual Query in After Progaurd

{"a":"feed","b":"query feed($limit: Int!, $fetchFrom: Long, $eventTypes: String, $profile: String, $group: Int) { feed(limit: $limit, fetchFrom: $fetchFrom, eventTypes: $eventTypes, profile: $profile, group: $group) { fetchFrom feed { type meta { type id body ref rating group { ...GroupFragment } image { ...ImageFragment } shares eventId profile { ...ProfileFragment } comments { id } createdAt editionId favorites isPrivate editorRawData hasUserFavorited previewImage{ ...ImageFragment } previewText views articleId readingTime scoop{ ...ScoopFragment } source { type meta { title type body ref createdAt updatedAt editionId edition { ...EditionFragment } profile { ...ProfileFragment } previewImage{ ...ImageFragment } previewText views articleId readingTime scoop{ ...ScoopFragment } } } edition { ...EditionFragment } isUserFollowingBook defaultCollection } } }}\n\nfragment ImageFragment on Image { baseUrl key}\n\nfragment GroupFragment on Group { id name avatar { ...ImageFragment } status}\n\nfragment ProfileFragment on Profile { avatar { ...ImageFragment } username displayName isFollowing }\n\nfragment ScoopFragment on Scoop { author title url urlToImage description source{ name } tags{ name slug }}\n\nfragment CoverFragment on EditionCover{ baseUrl key}\n\nfragment EditionFragment on Edition { title id description rating { edition average id count } type cover { ...CoverFragment } authors slug ISBN13 ISBNType createdAt}","c":{"limit":10},"d":{}}

wax911 commented 5 years ago

Currently only models are set in the proguard rules.

You should be able to define other rules in your application proguard, and perhaps make a PR when you've solved the issue?

Sorry I cannot attend to this immediately as I will be away for a week or so

Brajendra commented 5 years ago

@wax911 I solved this issue to define some of the rules in progaurd file.

-keep class io.github.wax911.library.model.* { ; } -keep class com.data.models.* { ; } . Your model objects

-keep class okhttp3. { *; } -keep interface okhttp3.* { ; } -dontwarn okhttp3. -dontwarn okio.**

-dontnote retrofit2.Platform -dontnote retrofit2.Platform$IOS$MainThreadExecutor

Platform used when running on Java 8 VMs. Will not be used at runtime.

-dontwarn retrofit2.Platform$Java8

Retain generic type information for use by reflection by converters and adapters.

-keepattributes Signature

Retain declared checked exceptions for use by a Proxy instance.

-keepattributes Exceptions

wax911 commented 5 years ago

My guess is you hadn't added -keep class io.github.wax911.library.model.** { ; } :thinking: glad to got it working :+1:

Brajendra commented 5 years ago

Thanks, can you please add this line in the readme file use for proguard, so users will not suffer. -keep class io.github.wax911.library.model.** { ; }

On Wed, Jun 19, 2019 at 11:57 AM Maxwell Mapako notifications@github.com wrote:

My guess is you hadn't added -keep class io.github.wax911.library.model.** { ; } 🤔

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AniTrend/retrofit-graphql/issues/18?email_source=notifications&email_token=AAOBRAL7P64XIZ7TRXWJVELP3HGTNA5CNFSM4HYU6QGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYA2QKA#issuecomment-503425064, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOBRAOOXEOJ2BRHSHB4JK3P3HGTNANCNFSM4HYU6QGA .

-- Thanks & Regards Brajendra Pandey Mobile +91-9650307763 Skypee brajendra.pandey2

wax911 commented 5 years ago

You've got a point, :smile: I'll update the read me docs to add the rules for future users :+1: