diff --git a/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchModsQuery.graphql b/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchModsQuery.graphql new file mode 100644 index 000000000..f6e36a08a --- /dev/null +++ b/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchModsQuery.graphql @@ -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 + } + } + } +} diff --git a/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchVipsQuery.graphql b/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchVipsQuery.graphql new file mode 100644 index 000000000..afce76261 --- /dev/null +++ b/graphql/src/main/graphql/com/github/twitch4j/graphql/internal/fetchVipsQuery.graphql @@ -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 + } + } + } +} diff --git a/graphql/src/main/java/com/github/twitch4j/graphql/TwitchGraphQL.java b/graphql/src/main/java/com/github/twitch4j/graphql/TwitchGraphQL.java index 93c83a975..6f5eb13f0 100644 --- a/graphql/src/main/java/com/github/twitch4j/graphql/TwitchGraphQL.java +++ b/graphql/src/main/java/com/github/twitch4j/graphql/TwitchGraphQL.java @@ -250,6 +250,10 @@ public CommandFetchModComments fetchModComments(OAuth2Credential auth, String ch return new CommandFetchModComments(getApolloClient(auth), channelId, targetId, after); } + public CommandFetchMods fetchMods(OAuth2Credential auth, String channelLogin, String after, Integer limit) { + return new CommandFetchMods(getApolloClient(auth), channelLogin, after, limit); + } + public CommandArchivePoll archivePoll(OAuth2Credential auth, String pollId) { return new CommandArchivePoll(getApolloClient(auth), pollId); } @@ -339,6 +343,10 @@ public CommandFetchVideoComments fetchVideoComments(OAuth2Credential auth, Strin return new CommandFetchVideoComments(getApolloClient(auth), channelId, videoId, id, after, before, first, last); } + public CommandFetchVips fetchVips(OAuth2Credential auth, String channelLogin, String after, Integer limit) { + return new CommandFetchVips(getApolloClient(auth), channelLogin, after, limit); + } + /** * Follow a user * diff --git a/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchMods.java b/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchMods.java new file mode 100644 index 000000000..5ba880e96 --- /dev/null +++ b/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchMods.java @@ -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 { + + /** + * 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 getGraphQLCall() { + return apolloClient.query( + FetchModsQuery.builder() + .channelLogin(channelLogin) + .after(cursor) + .first(limit) + .build() + ); + } +} diff --git a/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchVips.java b/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchVips.java new file mode 100644 index 000000000..0b5959f02 --- /dev/null +++ b/graphql/src/main/java/com/github/twitch4j/graphql/command/CommandFetchVips.java @@ -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 { + + /** + * 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 getGraphQLCall() { + return apolloClient.query( + FetchVipsQuery.builder() + .channelLogin(channelLogin) + .after(cursor) + .first(limit) + .build() + ); + } +}