Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch mods and vips over gql (#651)
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchModsQuery.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,19 @@ | ||
query fetchMods($channelLogin: String!, $first: Int = 10, $after: Cursor) { | ||
user(login: $channelLogin) { | ||
id | ||
mods(first: $first, after: $after) { | ||
edges { | ||
cursor | ||
grantedAt | ||
node { | ||
id | ||
displayName | ||
login | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchVipsQuery.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,19 @@ | ||
query fetchVips($channelLogin: String!, $first: Int = 10, $after: Cursor) { | ||
user(login: $channelLogin) { | ||
id | ||
vips(first: $first, after: $after) { | ||
edges { | ||
cursor | ||
grantedAt | ||
node { | ||
id | ||
displayName | ||
login | ||
} | ||
} | ||
pageInfo { | ||
hasNextPage | ||
} | ||
} | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchMods.java
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,49 @@ | ||
package com.github.twitch4j.graphql.command; | ||
|
||
import com.apollographql.apollo.ApolloCall; | ||
import com.apollographql.apollo.ApolloClient; | ||
import com.github.twitch4j.graphql.internal.FetchModsQuery; | ||
|
||
public class CommandFetchMods extends BaseCommand<FetchModsQuery.Data> { | ||
|
||
/** | ||
* The login name of the channel whose mod list is being queried | ||
*/ | ||
private final String channelLogin; | ||
|
||
/** | ||
* Relay cursor for forward pagination (optional) | ||
*/ | ||
private final String cursor; | ||
|
||
/** | ||
* The maximum number of nodes to return in a single call | ||
*/ | ||
private final int limit; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param apolloClient Apollo Client | ||
* @param channelLogin The login name of the channel whose mod list is being queried | ||
* @param cursor Relay cursor for forward pagination (optional) | ||
* @param limit The maximum number of nodes to return in a single call | ||
*/ | ||
public CommandFetchMods(ApolloClient apolloClient, String channelLogin, String cursor, Integer limit) { | ||
super(apolloClient); | ||
this.channelLogin = channelLogin; | ||
this.cursor = cursor; | ||
this.limit = limit != null ? limit : 100; | ||
} | ||
|
||
@Override | ||
protected ApolloCall<FetchModsQuery.Data> getGraphQLCall() { | ||
return apolloClient.query( | ||
FetchModsQuery.builder() | ||
.channelLogin(channelLogin) | ||
.after(cursor) | ||
.first(limit) | ||
.build() | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchVips.java
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,49 @@ | ||
package com.github.twitch4j.graphql.command; | ||
|
||
import com.apollographql.apollo.ApolloCall; | ||
import com.apollographql.apollo.ApolloClient; | ||
import com.github.twitch4j.graphql.internal.FetchVipsQuery; | ||
|
||
public class CommandFetchVips extends BaseCommand<FetchVipsQuery.Data> { | ||
|
||
/** | ||
* The login name of the channel whose vip list is being queried | ||
*/ | ||
private final String channelLogin; | ||
|
||
/** | ||
* Relay cursor for forward pagination (optional) | ||
*/ | ||
private final String cursor; | ||
|
||
/** | ||
* The maximum number of nodes to return in a single call | ||
*/ | ||
private final int limit; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param apolloClient Apollo Client | ||
* @param channelLogin The login name of the channel whose vip list is being queried | ||
* @param cursor Relay cursor for forward pagination (optional) | ||
* @param limit The maximum number of nodes to return in a single call | ||
*/ | ||
public CommandFetchVips(ApolloClient apolloClient, String channelLogin, String cursor, Integer limit) { | ||
super(apolloClient); | ||
this.channelLogin = channelLogin; | ||
this.cursor = cursor; | ||
this.limit = limit != null ? limit : 100; | ||
} | ||
|
||
@Override | ||
protected ApolloCall<FetchVipsQuery.Data> getGraphQLCall() { | ||
return apolloClient.query( | ||
FetchVipsQuery.builder() | ||
.channelLogin(channelLogin) | ||
.after(cursor) | ||
.first(limit) | ||
.build() | ||
); | ||
} | ||
} |