diff --git a/src/plugins/github/__snapshots__/graphql.test.js.snap b/src/plugins/github/__snapshots__/graphql.test.js.snap index fb1f2b6..2e12a74 100644 --- a/src/plugins/github/__snapshots__/graphql.test.js.snap +++ b/src/plugins/github/__snapshots__/graphql.test.js.snap @@ -217,6 +217,7 @@ exports[`plugins/github/graphql creates a query 1`] = ` ...pulls } defaultBranchRef { + id target { __typename ... on Commit { @@ -224,6 +225,18 @@ exports[`plugins/github/graphql creates a query 1`] = ` ...commitHistory } } + ... on Blob { + id + oid + } + ... on Tag { + id + oid + } + ... on Tree { + id + oid + } } } } diff --git a/src/plugins/github/example/example-github.json b/src/plugins/github/example/example-github.json index 5340585..b1f7f3e 100644 --- a/src/plugins/github/example/example-github.json +++ b/src/plugins/github/example/example-github.json @@ -1,6 +1,7 @@ { "repository": { "defaultBranchRef": { + "id": "MDM6UmVmMTIzMjU1MDA2Om1hc3Rlcg==", "target": { "__typename": "Commit", "history": { diff --git a/src/plugins/github/graphql.js b/src/plugins/github/graphql.js index 1a57ee0..ad2272c 100644 --- a/src/plugins/github/graphql.js +++ b/src/plugins/github/graphql.js @@ -119,16 +119,21 @@ export type RepositoryJSON = {| +pulls: ConnectionJSON, +url: string, +name: string, - +owner: AuthorJSON, + +owner: UserJSON | OrganizationJSON, +defaultBranchRef: ?RefJSON, |}; -export type RefJSON = {|+target: GitObjectJSON|}; +export type RefJSON = {|+id: string, +target: GitObjectJSON|}; export type GitObjectJSON = - | {|+__typename: "Commit", +history: ConnectionJSON|} - | {|+__typename: "Tree"|} - | {|+__typename: "Blob"|} - | {|+__typename: "Tag"|}; + | {| + +__typename: "Commit", + +id: string, + +oid: string, + +history: ConnectionJSON, + |} + | {|+__typename: "Tree", +id: string, +oid: string|} + | {|+__typename: "Blob", +id: string, +oid: string|} + | {|+__typename: "Tag", +id: string, +oid: string|}; /** * The top-level GitHub query to request data about a repository. @@ -159,6 +164,7 @@ export function createQuery(): Body { ]) ), b.field("defaultBranchRef", {}, [ + b.field("id"), b.field("target", {}, [ b.field("__typename"), b.inlineFragment("Commit", [ @@ -168,6 +174,9 @@ export function createQuery(): Body { [b.fragmentSpread("commitHistory")] ), ]), + b.inlineFragment("Blob", [b.field("id"), b.field("oid")]), + b.inlineFragment("Tag", [b.field("id"), b.field("oid")]), + b.inlineFragment("Tree", [b.field("id"), b.field("oid")]), ]), ]), ] @@ -871,12 +880,26 @@ function mergeDirect(destination: T, source: any): T { // Therefore, NullableAuthorJSON is preferred to AuthorJSON // for most actual usage. export type NullableAuthorJSON = AuthorJSON | null; -export type AuthorJSON = {| - +__typename: "User" | "Bot" | "Organization", +export type AuthorJSON = UserJSON | BotJSON | OrganizationJSON; +export type UserJSON = {| + +__typename: "User", +id: string, +login: string, +url: string, |}; +export type BotJSON = {| + +__typename: "Bot", + +id: string, + +login: string, + +url: string, +|}; +export type OrganizationJSON = {| + +__typename: "Organization", + +id: string, + +login: string, + +url: string, +|}; + function makePageInfo() { const b = build; return b.field("pageInfo", {}, [ @@ -1012,7 +1035,6 @@ export type ReviewJSON = {| +author: NullableAuthorJSON, +state: ReviewState, +comments: ConnectionJSON, - +reactions: ConnectionJSON, |}; function reviewsFragment(): FragmentDefinition { const b = build; @@ -1058,9 +1080,9 @@ export type CommitJSON = {| +id: string, +url: string, +oid: string, // the hash - +author: ?{| + +author: null | {| +date: /* ISO 8601 */ string, - +user: NullableAuthorJSON, + +user: null | UserJSON, |}, +message: string, +parents: ConnectionJSON<{|+oid: string|}>, @@ -1126,7 +1148,7 @@ export type ReactionContent = export type ReactionJSON = {| +id: string, +content: ReactionContent, - +user: NullableAuthorJSON, + +user: null | UserJSON, |}; function reactionsFragment(): FragmentDefinition {