Skip to content

Commit b04b4c9

Browse files
committed
wip
1 parent b76a483 commit b04b4c9

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

scripts/sync-landing-schema/get-contributors.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { readFile, writeFile } from "node:fs/promises"
33
import { fileURLToPath, pathToFileURL } from "node:url"
44
import { dirname, resolve } from "node:path"
55

6-
import { ExecutionResult } from "graphql"
6+
import type { ExecutionResult } from "graphql"
77

88
import { graphql } from "./generated/index.ts"
9-
import { TypedDocumentString } from "./generated/graphql.ts"
9+
import type { TypedDocumentString } from "./generated/graphql.ts"
1010

1111
type RepoRef = `${string}/${string}`
1212

@@ -190,8 +190,9 @@ async function fetchRepoContributors(
190190
break
191191
}
192192

193-
if (defaultBranchRef.target.__typename !== "Commit") {
194-
throw new Error(`Invalid typename for ${owner}/${repo}`)
193+
if (!("history" in defaultBranchRef.target)) {
194+
console.warn(`History not found for ${owner}/${repo}`)
195+
break
195196
}
196197

197198
const history = defaultBranchRef.target.history
@@ -245,20 +246,17 @@ async function execute<TResult, TVariables>(
245246
variables?: TVariables,
246247
headers?: Record<string, string>,
247248
): Promise<ExecutionResult<TResult>> {
248-
const response = await fetch("https://graphql.org/graphql/", {
249+
const response = await fetch("https://api.github.com/graphql", {
249250
method: "POST",
250251
headers: {
251252
"Content-Type": "application/json",
252-
Accept: "application/graphql-response+json",
253253
...headers,
254254
},
255-
body: JSON.stringify({
256-
query,
257-
variables,
258-
}),
255+
body: JSON.stringify({ query, variables }),
259256
})
260257

261258
if (!response.ok) {
259+
console.error("Network response was not ok:", response)
262260
throw new Error("Network response was not ok")
263261
}
264262

scripts/sync-landing-schema/graphql-codegen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ const config: CodegenConfig = {
4040
'import("$1.ts")',
4141
)
4242

43-
// switch type-only modules to type import
43+
// convert all imports to type imports
4444
content = content.replace(
45-
/import\s+({[^}]+})\s+from\s+['"]@graphql-typed-document-node\/core['"];?/g,
46-
'import type $1 from "@graphql-typed-document-node/core";',
45+
/import\s+({[^}]+})\s+from\s+['"]([^'"]+)['"];?/g,
46+
'import type $1 from "$2";',
4747
)
4848

4949
await writeFile(`./generated/${file}`, content)

0 commit comments

Comments
 (0)