How to use the @octokit/graphql.graphql function in @octokit/graphql

To help you get started, we’ve selected a few @octokit/graphql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / dev-spaces / actions / add-review-url-ts / src / AddReviewUrl.ts View on Github external
private async addCommentUsingSubjectId(pullRequestId: GraphQlQueryResponseData, comment: string) {
        console.log(`pullRequestId  ===>>>> ${pullRequestId}`)
        let data = JSON.parse(JSON.stringify(pullRequestId));
        console.log(`Parsed pull request id ${data}`)
        const token = core.getInput('repo-token');
        let graphQlResponse = graphql(this.addPullRequestCommentMutation(), {
                headers: {
                    authorization: `token ${token}`,
                },
                subjectId: data.repository.pullRequest.id,
                body: comment,

            },
        );
        console.log(`Adding the comment ...`);
        return await graphQlResponse;
    }
github Azure / dev-spaces / actions / add-review-url-ts / src / AddReviewUrl.ts View on Github external
private async getSubjectId(findPullRequestIdQuery: string, nameAndRepo: string[]) {
        console.log('Inside getSubjectId');
        const token = core.getInput('repo-token');
        let newVar: GraphQlQueryResponseData = await graphql(findPullRequestIdQuery, {
                headers: {
                    authorization: `token ${token}`,
                },
                owner: nameAndRepo[0],
                repo: nameAndRepo[1],
                pullNumber: this.getPullNumber(),
            },
        );
        console.log(`Exiting getSubject Id`);
        return newVar;
    }
github golangci / golangci-lint / .github / contributors / generate.ts View on Github external
const buildContributorInfo = async (contributors: WeightedContributor[]): Promise => {
  const query = `{
    ${contributors.map((c, i) => `user${i}: user(login: "${c.login}") {...UserFragment}`).join(`\n`)}
  }
    fragment UserFragment on User {
        login
        name
        websiteUrl
        avatarUrl
    }`

  try {
    const resp = await graphql.graphql(query, {
      headers: {
        authorization: `token ${process.env.GITHUB_TOKEN}`,
      },
    })

    return contributors.map((_, i) => resp[`user${i}`]).filter((v) => v)
  } catch (err) {
    if (err.errors && err.data) {
      console.warn(`github errors:`, err.errors)
      return contributors.map((_, i) => err.data[`user${i}`]).filter((v) => v)
    }
    throw err
  }
}
github Azure / dev-spaces / actions / add-review-url-ts / lib / AddReviewUrl.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            console.log('Inside getSubjectId');
            const token = core.getInput('repo-token');
            let newVar = yield graphql_1.graphql(findPullRequestIdQuery, {
                headers: {
                    authorization: `token ${token}`,
                },
                owner: nameAndRepo[0],
                repo: nameAndRepo[1],
                pullNumber: this.getPullNumber(),
            });
            console.log(`Exiting getSubject Id`);
            return newVar;
        });
    }
github Azure / dev-spaces / actions / add-review-url-ts / lib / AddReviewUrl.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            console.log(`pullRequestId  ===>>>> ${pullRequestId}`);
            let data = JSON.parse(JSON.stringify(pullRequestId));
            console.log(`Parsed pull request id ${data}`);
            const token = core.getInput('repo-token');
            let graphQlResponse = graphql_1.graphql(this.addPullRequestCommentMutation(), {
                headers: {
                    authorization: `token ${token}`,
                },
                subjectId: data.repository.pullRequest.id,
                body: comment,
            });
            console.log(`Adding the comment ...`);
            return yield graphQlResponse;
        });
    }
github intuit / auto / packages / core / src / git.ts View on Github external
async graphql(query: string) {
    this.logger.verbose.info('Querying Github using GraphQL:\n', query);

    const data = await graphql(query, {
      baseUrl: this.graphqlBaseUrl,
      headers: {
        authorization: `token ${this.options.token}`
      }
    });

    this.logger.veryVerbose.info('Got response from query\n', data);
    return data;
  }
github octokit / rest.js / scripts / update-endpoints / fetch-json.js View on Github external
async function main() {
  const { endpoints } = await graphql(QUERY, {
    url: "https://octokit-routes-graphql-server.now.sh/",
    version: process.env.VERSION
  });

  writeFileSync(
    path.resolve(__dirname, "generated", "endpoints.json"),
    prettier.format(JSON.stringify(endpoints), {
      parser: "json"
    })
  );
}
github Azure / dev-spaces / actions / add-review-url / src / AddReviewUrl.ts View on Github external
private async getSubjectId(findPullRequestIdQuery: string, nameAndRepo: string[]) {
        core.debug('Inside getSubjectId');
        const token = core.getInput('repo-token');
        let newVar: GraphQlQueryResponseData = await graphql(findPullRequestIdQuery, {
                headers: {
                    authorization: `token ${token}`,
                },
                owner: nameAndRepo[0],
                repo: nameAndRepo[1],
                pullNumber: this.getPullNumber(),
            },
        );
        core.debug(`Exiting getSubject Id`);
        return newVar;
    }
github octokit / plugin-throttling.js / scripts / update-endpoints / fetch-json.js View on Github external
async function main () {
  const { endpoints } = await graphql(QUERY, {
    url: 'https://octokit-routes-graphql-server.now.sh/',
    version: process.env.VERSION
  })

  writeFileSync(
    path.resolve(__dirname, 'generated', 'endpoints.json'),
    JSON.stringify(endpoints, null, 2) + '\n'
  )
}

@octokit/graphql

GitHub GraphQL API client for browsers and Node

MIT
Latest version published 6 months ago

Package Health Score

90 / 100
Full package analysis