-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50db0ac
commit b004985
Showing
23 changed files
with
605 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
query TestQuery { | ||
animal { | ||
age | ||
... on WarmBlooded { | ||
...BirdFragment | ||
celsius: temperature | ||
... on Pet { | ||
name | ||
} | ||
} | ||
|
||
... on Pet { | ||
nick: name | ||
} | ||
} | ||
} | ||
|
||
fragment BirdFragment on Bird { | ||
... on Eagle { | ||
wingSize | ||
} | ||
feathers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package inline_fragments | ||
|
||
class Data(val animal: Animal) { | ||
interface Animal { | ||
val age: Int | ||
} | ||
|
||
interface WarmBlooded { | ||
val celsius: Float | ||
interface Pet { | ||
val name: String | ||
} | ||
} | ||
|
||
interface Pet { | ||
val nick: String | ||
} | ||
} | ||
|
||
interface BirdFragment { | ||
interface Eagle { | ||
val wingSize: Float | ||
} | ||
val feathers: Int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
query GetHero { | ||
hero { | ||
friend { | ||
name | ||
} | ||
} | ||
} | ||
|
||
query GetHero { | ||
hero { | ||
friend @include(if: $condition) { | ||
...droidFragment | ||
id @include(if: $condition2) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package overlapping_fragments | ||
|
||
|
||
class Data(val hero: Hero) { | ||
interface Hero { | ||
val name: String | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A JVM project that generates models and also has server code for testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
kotlin("jvm").version("1.4.0").apply(false) | ||
id("com.apollographql.apollo").apply(false) | ||
kotlin("plugin.spring").version("1.4.0").apply(false) | ||
id("org.springframework.boot").version("2.3.3.RELEASE").apply(false) | ||
id("net.mbonnin.one.eight").version("0.1") | ||
} | ||
|
||
subprojects { | ||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
kotlin("jvm") | ||
id("com.apollographql.apollo") | ||
} | ||
|
||
dependencies { | ||
implementation("com.apollographql.apollo:apollo-runtime:${properties.get("apolloVersion")}") | ||
implementation("com.apollographql.apollo:apollo-coroutines-support:${properties.get("apolloVersion")}") | ||
implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:${properties.get("apolloVersion")}") | ||
|
||
implementation("org.jetbrains.kotlin:kotlin-test") | ||
implementation("com.squareup.okhttp3:logging-interceptor:4.8.1") | ||
implementation("junit:junit:4.13") | ||
implementation(project(":server")) | ||
} | ||
|
||
apollo { | ||
generateKotlinModels.set(true) | ||
} |
18 changes: 18 additions & 0 deletions
18
pets-server/client/src/main/graphql/com/example/operations.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
query getContent( | ||
$vendors: [Int!]!, | ||
$tags_filter_1: [Int!]!, | ||
$tags_filter_2: [Int!]! | ||
) { | ||
content( | ||
where:{ | ||
state: { _eq: "toto", numberInput: 0 }, | ||
vendor_id: {_in: $vendors}, | ||
_and : [ | ||
{ recipe_tags : { tag_id: {_in: $tags_filter_1}}}, | ||
{ recipe_tags : { tag_id: {_in: $tags_filter_2}}} | ||
] | ||
} | ||
) { | ||
id | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
pets-server/client/src/main/graphql/com/example/schema.sdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
interface Collection { | ||
items: [Item!]! | ||
} | ||
|
||
interface Item { | ||
title: String! | ||
} | ||
|
||
type ParticularCollection implements Collection { | ||
items: [Item!]! | ||
} | ||
|
||
type ParticularItem implements Item { | ||
image: String! | ||
title: String! | ||
} | ||
|
||
type Query { | ||
collections: [Collection!]! | ||
item: [Item!]! | ||
} | ||
|
||
type RegularCollection implements Collection { | ||
items: [Item!]! | ||
} | ||
|
||
type RegularItem implements Item { | ||
title: String! | ||
} | ||
|
||
schema { | ||
subscription: subscription | ||
query: Query | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import com.apollographql.apollo.ApolloClient | ||
import com.apollographql.apollo.cache.normalized.NormalizedCache | ||
import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy | ||
import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory | ||
import com.apollographql.apollo.coroutines.await | ||
import com.example.GetContentQuery | ||
import kotlinx.coroutines.runBlocking | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.junit.Test | ||
import server.runServer | ||
|
||
class MainTest { | ||
|
||
@Test | ||
fun test() { | ||
val applicationContext = runServer() | ||
|
||
runBlocking { | ||
val apolloClient = ApolloClient.builder() | ||
.okHttpClient(OkHttpClient.Builder().addInterceptor( | ||
HttpLoggingInterceptor().apply { | ||
level = HttpLoggingInterceptor.Level.BODY | ||
} | ||
).build()) | ||
.normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION)) | ||
.serverUrl("http://localhost:8080/graphql") | ||
.build() | ||
|
||
apolloClient.query(GetContentQuery(listOf(0), listOf(1), listOf(2))) | ||
.await() | ||
.let { | ||
println("got ${it.data} (fromCache: ${it.fromCache})") | ||
} | ||
|
||
println(NormalizedCache.prettifyDump(apolloClient.apolloStore.normalizedCache().dump())) | ||
apolloClient.query(GetContentQuery(listOf(0), listOf(1), listOf(3))) | ||
.await() | ||
.let { | ||
println("got ${it.data} (fromCache: ${it.fromCache})") | ||
} | ||
|
||
println(NormalizedCache.prettifyDump(apolloClient.apolloStore.normalizedCache().dump())) | ||
} | ||
applicationContext.close() | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apolloVersion=2.4.2 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.