@apollo/client/core#TypedDocumentNode TypeScript Examples
The following examples show how to use
@apollo/client/core#TypedDocumentNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: graphql-client.ts From dt-mergebot with MIT License | 6 votes |
export function createMutation<T>(name: keyof schema.Mutation, input: T, subquery?: string): MutationOptions<void, { input: T }> {
const mutation = {
toJSON: () => print(mutation),
...(gql`mutation($input: ${name[0]!.toUpperCase() + name.slice(1)}Input!) {
${name}(input: $input) {
__typename
${subquery || ""}
}
}` as TypedDocumentNode<void, { input: T }>),
};
return { mutation, variables: { input } };
}
Example #2
Source File: SHA1-to-PR-query.ts From dt-mergebot with MIT License | 6 votes |
GetPRForSHA1Query: TypedDocumentNode<GetPRForSHA1, GetPRForSHA1Variables> = gql`
query GetPRForSHA1($query: String!) {
search(query: $query, first: 1, type: ISSUE) {
nodes {
... on PullRequest {
title
number
closed
}
}
}
}`
Example #3
Source File: all-open-prs-query.ts From dt-mergebot with MIT License | 6 votes |
getAllOpenPRsAndCardIDsQuery: TypedDocumentNode<GetAllOpenPRsAndCardIDs, GetAllOpenPRsAndCardIDsVariables> = gql`
query GetAllOpenPRsAndCardIDs($endCursor: String) {
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
id
pullRequests(states: OPEN, orderBy: { field: UPDATED_AT, direction: DESC }, first: 100, after: $endCursor) {
nodes {
number
projectCards(first: 100) { nodes { id } }
}
pageInfo { hasNextPage endCursor }
}
}
}`
Example #4
Source File: card-id-to-pr-query.ts From dt-mergebot with MIT License | 6 votes |
runQueryToGetPRForCardId = async (id: string): Promise<CardPRInfo | undefined> => {
const info = await client.query({
query: gql`
query CardIdToPr($id: ID!) {
node(id: $id) {
... on ProjectCard { content { ... on PullRequest { state number } } }
}
}` as TypedDocumentNode<CardIdToPr, CardIdToPrVariables>,
variables: { id },
fetchPolicy: "no-cache",
});
const node = info.data.node;
return (node?.__typename === "ProjectCard" && node.content?.__typename === "PullRequest")
? { number: node.content.number, state: node.content.state }
: undefined;
}
Example #5
Source File: file-query.ts From dt-mergebot with MIT License | 6 votes |
GetFileContent: TypedDocumentNode<GetFileContent, GetFileContentVariables> = gql`
query GetFileContent($owner: String!, $name: String!, $expr: String!) {
repository(owner: $owner, name: $name) {
id
object(expression: $expr) {
... on Blob {
text
byteSize
}
}
}
}`
Example #6
Source File: label-columns-queries.ts From dt-mergebot with MIT License | 6 votes |
GetLabelsQuery: TypedDocumentNode<GetLabels, GetLabelsVariables> = gql`
query GetLabels($endCursor: String) {
repository(name: "DefinitelyTyped", owner: "DefinitelyTyped") {
id
labels(first: 100, after: $endCursor) {
nodes {
id
name
}
pageInfo { hasNextPage endCursor }
}
}
}`
Example #7
Source File: label-columns-queries.ts From dt-mergebot with MIT License | 6 votes |
GetProjectColumns: TypedDocumentNode<GetProjectColumns, never> = gql`
query GetProjectColumns {
repository(name:"DefinitelyTyped", owner:"DefinitelyTyped") {
id
project(number: 5) {
id
columns(first: 30) {
nodes {
id
name
}
}
}
}
}`
Example #8
Source File: pr-query.ts From dt-mergebot with MIT License | 6 votes |
GetPRInfoQueryRest: TypedDocumentNode<PRFiles, PRFilesVariables> = gql`
query PRFiles($prNumber: Int!, $endCursor: String) {
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
pullRequest(number: $prNumber) {
files(first: 100, after: $endCursor) {
totalCount
nodes {
path
additions
deletions
}
pageInfo { hasNextPage endCursor }
}
}
}
}
`
Example #9
Source File: projectboard-cards.ts From dt-mergebot with MIT License | 6 votes |
GetProjectBoardCardsQuery: TypedDocumentNode<GetProjectBoardCards, never> = gql`
query GetProjectBoardCards {
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
id
project(number: 5) {
id
columns(first: 100) {
nodes {
id
name
cards(last: 100) {
totalCount
nodes {
id
updatedAt
}
}
}
}
}
}
}`
Example #10
Source File: cachedQueries.ts From dt-mergebot with MIT License | 5 votes |
async function query<T>(gql: TypedDocumentNode<T>): Promise<T> {
const res = await client.query({ query: gql });
return res.data;
}
Example #11
Source File: pr-query.ts From dt-mergebot with MIT License | 4 votes |
GetPRInfoQueryFirst: TypedDocumentNode<PR, PRVariables> = gql`
query PR($prNumber: Int!) {
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
id
pullRequest(number: $prNumber) {
id
title
createdAt
author {
login
}
authorAssociation
baseRef {
name
}
labels(first: 100) {
nodes {
name
}
}
isDraft
mergeable
number
state
headRefOid
changedFiles
additions
deletions
commitIds: commits(last: 100) { nodes { commit { oid parents(first: 3) { nodes { oid }}}}}
timelineItems(last: 200, itemTypes: [REOPENED_EVENT, READY_FOR_REVIEW_EVENT,
MOVED_COLUMNS_IN_PROJECT_EVENT]) {
nodes {
... on ReopenedEvent {
createdAt
}
... on ReadyForReviewEvent {
createdAt
}
... on MovedColumnsInProjectEvent {
actor { login }
createdAt
projectColumnName
}
}
}
reviews(last: 100) {
nodes {
author {
login
}
commit {
oid
}
comments(last: 10) {
nodes {
author {
login
}
createdAt
}
}
authorAssociation
state
submittedAt
url
}
}
commits(last: 1) {
totalCount
nodes {
commit {
checkSuites(first: 100) {
nodes {
databaseId
app {
name
}
conclusion
resourcePath
status
url
checkRuns(last: 1) {
nodes {
title
}
}
}
}
status {
state
contexts {
state
description
creator { login }
targetUrl
}
}
authoredDate
committedDate
pushedDate
oid
}
}
}
comments(last: 100) {
totalCount
nodes {
id
author {
login
}
databaseId
body
createdAt
reactions(first: 100, content: THUMBS_UP) {
nodes {
user { login }
}
}
}
}
files(first: 100) {
totalCount
nodes {
path
additions
deletions
}
pageInfo { hasNextPage endCursor }
}
projectCards(first: 10) {
nodes {
id
project {
id
number
name
}
column {
id
name
}
}
}
}
}
}
`