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

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

Open
williammartin opened this issue Feb 22, 2024 · 2 comments
Open

Comments

@williammartin
Copy link

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;

Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@williammartin williammartin changed the title Are the cursor examples in the README.md expected to work? Are the (cursor) => examples in the README.md expected to work? Feb 22, 2024
@williammartin
Copy link
Author

williammartin commented Feb 22, 2024

Since I cloned this repo to add some automated tests I actually tried to use this shape of request with TypeScript and it doesn't typecheck so I can't see how these examples would ever have worked:

Image

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

No branches or pull requests

1 participant