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

chore(deps): update dependency prettier to v3 #92

Merged
merged 3 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const { repository } = await octokit.graphql.paginate(
}
}
}
}`
}`,
);

console.log(`Found ${repository.issues.nodes.length} issues!`);
Expand Down Expand Up @@ -95,7 +95,7 @@ const pageIterator = octokit.graphql.paginate.iterator(
}
}
}
}`
}`,
);

for await (const response of pageIterator) {
Expand Down Expand Up @@ -127,7 +127,7 @@ await octokit.graphql.paginate(
`,
{
organization: "octokit",
}
},
);
```

Expand All @@ -153,7 +153,7 @@ await octokit.graphql.paginate(
{
organization: "octokit",
cursor: "initialValue",
}
},
);
```

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"glob": "^10.2.6",
"jest": "^29.0.0",
"npm-run-all": "^4.1.5",
"prettier": "2.8.8",
"prettier": "3.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
Expand Down
8 changes: 4 additions & 4 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type { CursorValue, PageInfoContext } from "./page-info";
// Todo: Add link to explanation
const generateMessage = (path: string[], cursorValue: CursorValue): string =>
`The cursor at "${path.join(
","
",",
)}" did not change its value "${cursorValue}" after a page transition. Please make sure your that your query is set up correctly.`;

class MissingCursorChange extends Error {
override name = "MissingCursorChangeError";

constructor(
readonly pageInfo: PageInfoContext,
readonly cursorValue: CursorValue
readonly cursorValue: CursorValue,
) {
super(generateMessage(pageInfo.pathInQuery, cursorValue));

Expand All @@ -29,8 +29,8 @@ class MissingPageInfo extends Error {
`No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
response,
null,
2
)}`
2,
)}`,
);

if (Error.captureStackTrace) {
Expand Down
4 changes: 2 additions & 2 deletions src/iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MissingCursorChange } from "./errors";
const createIterator = (octokit: Octokit) => {
return <ResponseType = any>(
query: string,
initialParameters: Record<string, any> = {}
initialParameters: Record<string, any> = {},
) => {
let nextPageExists = true;
let parameters = { ...initialParameters };
Expand All @@ -18,7 +18,7 @@ const createIterator = (octokit: Octokit) => {

const response = await octokit.graphql<ResponseType>(
query,
parameters
parameters,
);

const pageInfoContext = extractPageInfos(response);
Expand Down
2 changes: 1 addition & 1 deletion src/merge-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { findPaginatedResourcePath, get, set } from "./object-helpers";

const mergeResponses = <ResponseType extends object = any>(
response1: ResponseType,
response2: ResponseType
response2: ResponseType,
): ResponseType => {
if (Object.keys(response1).length === 0) {
return Object.assign(response1, response2);
Expand Down
6 changes: 3 additions & 3 deletions src/object-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isObject = (value: any) =>
function findPaginatedResourcePath(responseData: any): string[] {
const paginatedResourcePath = deepFindPathToProperty(
responseData,
"pageInfo"
"pageInfo",
);
if (paginatedResourcePath.length === 0) {
throw new MissingPageInfo(responseData);
Expand All @@ -17,7 +17,7 @@ function findPaginatedResourcePath(responseData: any): string[] {
const deepFindPathToProperty = (
object: any,
searchProp: string,
path: string[] = []
path: string[] = [],
): string[] => {
for (const key of Object.keys(object)) {
const currentPath = [...path, key];
Expand All @@ -31,7 +31,7 @@ const deepFindPathToProperty = (
const result = deepFindPathToProperty(
currentValue,
searchProp,
currentPath
currentPath,
);
if (result.length > 0) {
return result;
Expand Down
2 changes: 1 addition & 1 deletion src/page-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type PageInfoContext = {
};

const isForwardSearch = (
givenPageInfo: PageInfo
givenPageInfo: PageInfo,
): givenPageInfo is PageInfoForward => {
return givenPageInfo.hasOwnProperty("hasNextPage");
};
Expand Down
4 changes: 2 additions & 2 deletions src/paginate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const createPaginate = (octokit: Octokit) => {
const iterator = createIterator(octokit);
return async <ResponseType extends object = any>(
query: string,
initialParameters: Record<string, any> = {}
initialParameters: Record<string, any> = {},
): Promise<ResponseType> => {
let mergedResponse: ResponseType = {} as ResponseType;
for await (const response of iterator<ResponseType>(
query,
initialParameters
initialParameters,
)) {
mergedResponse = mergeResponses<ResponseType>(mergedResponse, response);
}
Expand Down
6 changes: 3 additions & 3 deletions test/paginate-graphql.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PatchedOctokit = Octokit.plugin(paginateGraphql);
const token = process.env.E2E_GITHUB_TOKEN;
if (!token) {
throw new Error(
"Executing the E2E Tests requires you to pass a GitHub Token as an environment variable named E2E_GITHUB_TOKEN"
"Executing the E2E Tests requires you to pass a GitHub Token as an environment variable named E2E_GITHUB_TOKEN",
);
}

Expand All @@ -30,7 +30,7 @@ describe("paginate-graphql-js E2E Test", () => {
}
}
}
}`
}`,
);
expect(result).toBeDefined();
expect(result.repository.repositoryTopics.nodes).toHaveLength(3);
Expand All @@ -55,7 +55,7 @@ describe("paginate-graphql-js E2E Test", () => {
}
}
}
}`
}`,
);

let iterations = 0;
Expand Down
16 changes: 8 additions & 8 deletions test/paginate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("pagination", () => {
}
}
`,
{ cursor: "initialValue", organization: "octokit" }
{ cursor: "initialValue", organization: "octokit" },
);

expect(getPassedVariablesForCall(1)).toEqual({
Expand Down Expand Up @@ -225,7 +225,7 @@ describe("pagination", () => {
}
}
}
}`
}`,
);

expect(getCallCount()).toBe(2);
Expand Down Expand Up @@ -258,7 +258,7 @@ describe("pagination", () => {
}
}
}
}`
}`,
);

const allIssues: any[] = [];
Expand Down Expand Up @@ -305,13 +305,13 @@ describe("pagination", () => {
}
}
}
}`
}`,
);
throw new Error("Should not succeed!");
} catch (err: any) {
expect(err).toBeInstanceOf(MissingCursorChange);
expect(err.message).toMatch(
/The cursor at "repository.issues" did not change its value "endCursor1".*/
/The cursor at "repository.issues" did not change its value "endCursor1".*/,
);
}
});
Expand Down Expand Up @@ -349,8 +349,8 @@ describe("pagination", () => {
`No pageInfo property found in response. Please make sure to specify the pageInfo in your query. Response-Data: ${JSON.stringify(
response,
null,
2
)}`
2,
)}`,
);
}
});
Expand Down Expand Up @@ -389,7 +389,7 @@ describe("pagination", () => {
.catch((error) => {
expect(error.message).toEqual(
"Request failed due to following response errors:\n" +
" - Field 'bioHtml' doesn't exist on type 'User'"
" - Field 'bioHtml' doesn't exist on type 'User'",
);
expect(error.errors).toStrictEqual(mockResponse.errors);
expect(error.request.query).toEqual(query);
Expand Down
2 changes: 1 addition & 1 deletion test/testHelpers/mock-octokit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MockOctokit = ({ responses = [{}] }: { responses?: any[] } = {}) => {
callCount = callCount + 1;
return { data: responses.shift() };
},
{ repeat: responses.length }
{ repeat: responses.length },
);

const octokit = new PatchedOctokit({
Expand Down