0

A month or 2 ago I wrote a query and codegen'd it into an SDK and deployed the code:

query OrgReposAg(
  $organization: String!
  $pageSize: Int
  $after: String
) {
  organization(login: $organization) {
    repositories(
      after: $after
      pageSize: $pageSize
      orderBy: { field: STARGAZERS, direction: DESC }
    ) {
      totalCount
      pageInfo {
        startCursor
        hasNextPage
        endCursor
      }
      edges {
        cursor
        node {
        ...MyRepoFields
        }
      }
    }
  }
}

fragment MyRepoFields on Repository {
  repositoryName: name
  id
  url
  descriptionHTML
  updatedAt
  stargazers {
    totalCount
  }
  forks {
    totalCount
  }
  issues(states: [OPEN]) {
    totalCount
  }
  pullRequests(states: [OPEN]) {
    totalCount
  }
}

I came back this weekend to edit it, codegen says the repositories.pagesize isn't a valid field - even though the deployed code is still running and getting results. I tested this on GitHub GraphQL explorer and it throws the same error.

I refactored the code for the GitHub GraphQL schema to work

query OrgReposAg_v2(
  $organization: String!
  $pageSize: Int
  $after: String
) {
  organization(login: $organization) {
    repositories(
      first: $pageSize
      after: $after
      orderBy: { field: STARGAZERS, direction: DESC }
    ) {
      totalCount
      pageInfo {
        startCursor
        hasNextPage
        endCursor
      }
      edges {
        cursor
        node {
        ...MyRepoFields
        }
      }
    }
  }
}

fragment MyRepoFields on Repository {
  repositoryName: name
  id
  url
  descriptionHTML
  updatedAt
  stargazers {
    totalCount
  }
  forks {
    totalCount
  }
  issues(states: [OPEN]) {
    totalCount
  }
  pullRequests(states: [OPEN]) {
    totalCount
  }
}

Why does the 1st/deploy'd query fetch data if it doesn't even compile against the schema? How do I keep up with these schema changes?

DFBerry
  • 1,818
  • 1
  • 19
  • 37

0 Answers0