Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetRepos query #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

heavenshell
Copy link
Contributor

@heavenshell heavenshell commented Jul 2, 2019

TL;DR

指定したユーザー(owner) のリポジトリー一覧を返す Query を書いてみた

スクリーンショット 2019-07-02 22 38 40

  • 下記が src/generate/graphql.tsx に吐かれてること
export const GetReposDocument = gql`
  query GetRepos($owner: String!) {
    user(login: $owner) {
      repositories(last: 100, orderBy: { field: UPDATED_AT, direction: DESC }) {
        totalCount
        pageInfo {
          hasNextPage
          hasPreviousPage
        }
        edges {
          cursor
          node {
            name
            url
            createdAt
          }
        }
      }
    }
  }
`;

export function useGetReposQuery(
  baseOptions?: ReactApolloHooks.QueryHookOptions<GetReposQueryVariables>
) {
  return ReactApolloHooks.useQuery<GetReposQuery, GetReposQueryVariables>(
    GetReposDocument,
    baseOptions
  );
}

@@ -0,0 +1,20 @@
query GetRepos($owner: String!) {
user(login: $owner) {
repositories(last: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[help]
ページングは after で cursor を文字列で指定するんだけど、hasNext(Prev) が true の場合、
ページングさせたいんだけど、どうやったら良いのかが分からない。

Copy link
Member

Choose a reason for hiding this comment

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

pageInfo {
  hasNextPage,
  hasPreviousPage,
  endCursor,
  startCursor
}

とかにしておいて、引数でend(start)Cursor 位置を受け付けるとかかな?

}
edges {
cursor,
node {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

他に欲しいものあるかしら?

Copy link
Member

Choose a reason for hiding this comment

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

updatedAt とか使うかも?
最近の更新順で表示したいときとか。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants