Skip to content

Commit

Permalink
feat: migrate to Apollo4
Browse files Browse the repository at this point in the history
  • Loading branch information
alvr committed Jan 26, 2024
1 parent f267463 commit 37731d3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,27 @@ internal class KatanaMultiplatformDataRemotePlugin : Plugin<Project> {
private fun ApolloExtension.configureApollo() {
service("anilist") {
generateAsInternal.set(true)
generateDataBuilders.set(true)
packageName.set(fullPackageName)

if (fullPackageName.contains(BASE_PACKAGE)) {
alwaysGenerateTypesMatching.set(listOf("Query", "User"))
generateApolloMetadata.set(true)
generateAsInternal.set(false)

introspection {
endpointUrl.set("https://graphql.anilist.co")
schemaFile.set(project.file("src/commonMain/graphql/schema.graphqls"))
}
} else {
val baseProject = project.project(BASE_PROJECT)

generateDataBuilders.set(true)
isADependencyOf(baseProject)
dependsOn(baseProject)
}
}
}

private companion object {
const val BASE_PROJECT = ":data:remote:base"
const val BASE_PACKAGE = ".base"
}
}
4 changes: 0 additions & 4 deletions data/remote/account/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
id("katana.multiplatform.data.remote")
}

dependencies {
apolloMetadata(projects.data.remote.base)
}

katanaMultiplatform {
commonMainDependencies {
implementation(projects.data.remote.base)
Expand Down
65 changes: 31 additions & 34 deletions data/remote/base/src/commonMain/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,6 @@ type Query {
ExternalLinkSourceCollection("Filter by the link id" id: Int, type: ExternalLinkType, mediaType: ExternalLinkMediaType): [MediaExternalLink]
}

"""
The `Int` scalar type represents non-fractional signed whole numeric
values. Int can represent values between -(2^31) and 2^31 - 1.
"""
scalar Int

"""
Page of data
"""
Expand Down Expand Up @@ -208,18 +202,6 @@ type PageInfo {
hasNextPage: Boolean
}

"""
The `Boolean` scalar type represents `true` or `false`.
"""
scalar Boolean

"""
The `String` scalar type represents textual data, represented as UTF-8
character sequences. The String type is most often used by GraphQL to
represent free-form human-readable text.
"""
scalar String

"""
User sort enums
"""
Expand Down Expand Up @@ -2579,13 +2561,6 @@ type MediaList {
user: User
}

"""
The `Float` scalar type represents signed double-precision fractional
values as specified by
[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).
"""
scalar Float

"""
Review sort enums
"""
Expand Down Expand Up @@ -3516,6 +3491,9 @@ enum AiringSort {
EPISODE_DESC
}

"""
Notification union type
"""
union NotificationUnion = AiringNotification|FollowingNotification|ActivityMessageNotification|ActivityMentionNotification|ActivityReplyNotification|ActivityReplySubscribedNotification|ActivityLikeNotification|ActivityReplyLikeNotification|ThreadCommentMentionNotification|ThreadCommentReplyNotification|ThreadCommentSubscribedNotification|ThreadCommentLikeNotification|ThreadLikeNotification|RelatedMediaAdditionNotification|MediaDataChangeNotification|MediaMergeNotification|MediaDeletionNotification

"""
Expand Down Expand Up @@ -3853,6 +3831,9 @@ type ActivityMentionNotification {
user: User
}

"""
Activity union type
"""
union ActivityUnion = TextActivity|ListActivity|MessageActivity

"""
Expand Down Expand Up @@ -5252,6 +5233,9 @@ type Deleted {
deleted: Boolean
}

"""
Likeable union type
"""
union LikeableUnion = ListActivity|TextActivity|MessageActivity|ActivityReply|Thread|ThreadComment

input AniChartHighlightInput {
Expand Down Expand Up @@ -5863,15 +5847,8 @@ type UserModData {
email: String
}

"""
The `ID` scalar type represents a unique identifier, often used to
refetch an object or as key for a cache. The ID type appears in a JSON
response as a String; however, it is not intended to be human-readable.
When expected as an input type, any string (such as `"4"`) or integer
(such as `4`) input value will be accepted as an ID.
"""
scalar ID

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.
"""
Expand Down Expand Up @@ -5902,6 +5879,8 @@ type __Schema {
directives: [__Directive!]!
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.
Expand All @@ -5927,6 +5906,8 @@ type __Type {
ofType: __Type
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
An enum describing what kind of type a given `__Type` is.
"""
Expand Down Expand Up @@ -5972,6 +5953,8 @@ enum __TypeKind {
NON_NULL
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.
"""
Expand All @@ -5989,6 +5972,8 @@ type __Field {
deprecationReason: String
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.
"""
Expand All @@ -6005,6 +5990,8 @@ type __InputValue {
defaultValue: String
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.
"""
Expand All @@ -6018,6 +6005,8 @@ type __EnumValue {
deprecationReason: String
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
Expand All @@ -6039,6 +6028,8 @@ type __Directive {
onField: Boolean! @deprecated(reason: "Use `locations`.")
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
"""
Expand Down Expand Up @@ -6134,16 +6125,22 @@ enum __DirectiveLocation {
INPUT_FIELD_DEFINITION
}

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
Directs the executor to include this field or fragment only when the `if` argument is true.
"""
directive @include ("Included when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
Directs the executor to skip this field or fragment when the `if` argument is true.
"""
directive @skip ("Skipped when true." if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT

# See https://github.com/JetBrains/js-graphql-intellij-plugin/issues/665
# noinspection GraphQLTypeRedefinition
"""
Marks an element of a GraphQL schema as no longer supported.
"""
Expand Down
4 changes: 0 additions & 4 deletions data/remote/explore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
id("katana.multiplatform.data.remote")
}

dependencies {
apolloMetadata(projects.data.remote.base)
}

katanaMultiplatform {
commonMainDependencies {
implementation(projects.data.remote.base)
Expand Down
4 changes: 0 additions & 4 deletions data/remote/lists/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
id("katana.multiplatform.data.remote")
}

dependencies {
apolloMetadata(projects.data.remote.base)
}

katanaMultiplatform {
commonMainDependencies {
implementation(projects.common.core)
Expand Down
4 changes: 0 additions & 4 deletions data/remote/social/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
id("katana.multiplatform.data.remote")
}

dependencies {
apolloMetadata(projects.data.remote.base)
}

katanaMultiplatform {
commonMainDependencies {
implementation(projects.data.remote.base)
Expand Down
4 changes: 0 additions & 4 deletions data/remote/user/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins {
id("katana.multiplatform.data.remote")
}

dependencies {
apolloMetadata(projects.data.remote.base)
}

katanaMultiplatform {
commonMainDependencies {
implementation(projects.common.core)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
activity = "1.8.2"
android = "8.2.2"
apollo = "3.8.2"
apollo = "4.0.0-beta.4"
arrow = "1.2.1"
buildconfig = "5.3.5"
complete-kotlin = "1.1.0"
Expand Down

0 comments on commit 37731d3

Please sign in to comment.