Skip to content

Are the (cursor) => examples in the README.md expected to work? #169

@williammartin

Description

@williammartin

I’ve been going through the examples in the README, but I can’t seem to get the examples with the (cursor) => pattern to work.

For example taking the TS example and making it JS:

octokit.graphql.paginate((cursor) => {
  return `{
      repository(owner: "octokit", name: "rest.js") {
        issues(first: 10, after: ${cursor.create()}) {
          nodes {
            title
          }
          pageInfo {
            hasNextPage
            endCursor
          }
        }
      }
    }`;
}).then(console.log);

I get one of these gnarly errors:

/Users/williammartin/workspace/octokit-playground/node_modules/@octokit/graphql/dist-node/index.js:113
      throw new GraphqlResponseError(
            ^

GraphqlResponseError: Request failed due to following response errors:
 - A query attribute must be specified and must be a string.

I also can’t find any examples in the wild of this pattern of usage:

https://github.com/search?type=code&q=%2Foctokit%5C.graphql%5C.paginate%3C.*%3E%5C%28%5C%28cursor%5C%29%2F
https://github.com/search?type=code&q=octokit.graphql.paginate%28%28cursor%29

And my pretty questionable TS reading of the type signature tells me this shouldn’t be possible?

return async <ResponseType extends object = any>(
query: string,
initialParameters: Record<string, any> = {},
): Promise<ResponseType> => {
let mergedResponse: ResponseType = {} as ResponseType;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🔥 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions