generated from Bullrich/parity-action-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #16 - Added Graphql implementation to get `viewerCanUpdateBranch` field. - Filtered PRs which have this value false - Implemented [`GraphQL-Codegen`](https://the-guild.dev/graphql/codegen) - Updated types to be extracted from `@octokit/graphql-schema` and auto-generated. - The type that implements this looks messy because all the nested objects are nullable - Added utility to copy `graphql` files into raw strings - Updated version to `0.2.1`
- Loading branch information
Showing
12 changed files
with
2,480 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
node_modules | ||
dist | ||
.git | ||
|
||
# Graphql Generated files | ||
src/github/queries/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,6 @@ | |
!.vscode/extensions.json | ||
!.vscode/settings.json | ||
.idea | ||
|
||
# Graphql Generated files | ||
src/github/queries/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: CodegenConfig = { | ||
overwrite: true, | ||
schema: "./node_modules/@octokit/graphql-schema/schema.graphql", | ||
documents: "src/**/*.graphql", | ||
generates: { | ||
"src/github/queries/index.ts": { | ||
plugins: ["typescript", "typescript-operations"] | ||
} | ||
} | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { readdirSync, writeFileSync, readFileSync } = require("fs"); | ||
|
||
const files = readdirSync("src/github/queries/"); | ||
|
||
/** | ||
* Copy a file and replace it's extension | ||
* @param {string} fileName Name of the file to copy | ||
* @param {string} extension New extension to put | ||
*/ | ||
const copyFile = (fileName, extension) => { | ||
console.log("Copying content of %s into a .ts file", fileName); | ||
const content = readFileSync(fileName); | ||
const oldExtension = fileName.split(".").pop(); | ||
writeFileSync( | ||
fileName.replace(oldExtension, extension), | ||
`// Generated from ${fileName}\nexport default \`${content}\`;`, | ||
); | ||
}; | ||
|
||
for (const file of files) { | ||
if (file.endsWith(".graphql")) { | ||
copyFile(`src/github/queries/${file}`, "ts"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
query PullRequests($cursor: String, $owner: String!, $repo: String!) { | ||
repository(owner: $owner, name: $repo) { | ||
pullRequests( | ||
first: 100 | ||
states: OPEN | ||
orderBy: { field: UPDATED_AT, direction: ASC } | ||
after: $cursor) { | ||
edges { | ||
node { | ||
number | ||
title | ||
viewerCanUpdateBranch | ||
isDraft | ||
autoMergeRequest { | ||
enabledAt | ||
} | ||
} | ||
} | ||
pageInfo { | ||
endCursor | ||
startCursor | ||
hasNextPage | ||
hasPreviousPage | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ | |
}, | ||
"exclude": [ | ||
"node_modules", | ||
"codegen.ts" | ||
] | ||
} |
Oops, something went wrong.