Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ QueryRootQuery query = Storefront.query(new Storefront.QueryRootQueryDefinition(
})
```

**Kotlin**
```kotlin
val query = Storefront.query { query ->
query.shop { shop ->
shop.name()
}
}
```

In this example:

- `Storefront.query` is the entry point for building GraphQL queries.
Expand Down Expand Up @@ -238,6 +247,22 @@ Storefront.query(rootQueryBuilder ->
);
```

**Kotlin**
```kotlin
val query = Storefront.query { query ->
query.node(ID("NkZmFzZGZhc"), { nodeQuery ->
nodeQuery.onCollection { collectionQuery ->
collectionQuery.withAlias("collection").title().description()
}
}).node(ID("GZhc2Rm"), { nodeQuery ->
nodeQuery.onCollection { collectionQuery ->
collectionQuery.withAlias("product").title().description()
}
})
}
```


Accessing the aliased nodes is similar to a plain node:

```java
Expand Down Expand Up @@ -269,6 +294,22 @@ GraphClient.builder(this)
.build()
```

**Kotlin**
```kotlin
val okHttpClient = OkHttpClient.Builder()
.addNetworkInterceptor(HttpLoggingInterceptor().setLevel(BuildConfig.OKHTTP_LOG_LEVEL))
.build()

GraphClient.build(context, BuildConfig.SHOP_DOMAIN, BuildConfig.API_KEY) {
this.httpClient = okHttpClient
httpCache(context.cacheDir, configure = {
cacheMaxSizeBytes = 1024 * 1024 * 10
defaultCachePolicy = CACHE_FIRST.expireAfter(20, TimeUnit.MINUTES)
})
}
```


GraphQL specifies two types of operations: queries and mutations. The `GraphClient` exposes these as two type-safe operations, while also offering some conveniences for retrying and polling in each.

### Queries [⤴](#table-of-contents)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am facing this issue when use above code to create graphClient

java.lang.NoSuchMethodError: No static method create(Lokhttp3/internal/io/FileSystem;Ljava/io/File;IIJ)Lokhttp3/internal/cache/DiskLruCache; in class Lokhttp3/internal/cache/DiskLruCache; or its super classes (declaration of 'okhttp3.internal.cache.DiskLruCache' appears in /data/app/com.ganesh.shopify_test-wt4PKIJFzZqPmil4mqs4-w==/base.apk)

Expand Down