Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -3,7 +3,7 @@
> GitHub GraphQL API client for browsers and Node
[![@latest](https://img.shields.io/npm/v/@octokit/graphql.svg)](https://www.npmjs.com/package/@octokit/graphql)
[![Build Status](https://github.com/octokit/graphql.js/workflows/Test/badge.svg)](https://github.com/octokit/graphql.js/actions?query=workflow%3ATest+branch%3Amaster)
[![Build Status](https://github.com/octokit/graphql.js/workflows/Test/badge.svg)](https://github.com/octokit/graphql.js/actions?query=workflow%3ATest+branch%3Amain)
<!-- toc -->
@ -14,6 +14,8 @@
- [Pass query together with headers and variables](#pass-query-together-with-headers-and-variables)
- [Use with GitHub Enterprise](#use-with-github-enterprise)
- [Use custom `@octokit/request` instance](#use-custom-octokitrequest-instance)
- [TypeScript](#typescript)
- [Additional Types](#additional-types)
- [Errors](#errors)
- [Partial responses](#partial-responses)
- [Writing tests](#writing-tests)
@ -29,11 +31,11 @@
Browsers
</th><td width=100%>
Load `@octokit/graphql` directly from [cdn.pika.dev](https://cdn.pika.dev)
Load `@octokit/graphql` directly from [esm.sh](https://esm.sh)
```html
<script type="module">
import { endpoint } from "https://cdn.pika.dev/@octokit/graphql";
import { graphql } from "https://esm.sh/@octokit/graphql";
</script>
```
@ -74,7 +76,7 @@ const { repository } = await graphql(
headers: {
authorization: `token secret123`,
},
}
},
);
```
@ -108,7 +110,7 @@ For more complex authentication strategies such as GitHub Apps or Basic, we reco
```js
const { createAppAuth } = require("@octokit/auth-app");
const auth = createAppAuth({
id: process.env.APP_ID,
appId: process.env.APP_ID,
privateKey: process.env.PRIVATE_KEY,
installationId: 123,
});
@ -129,7 +131,7 @@ const { repository } = await graphqlWithAuth(
}
}
}
}`
}`,
);
```
@ -158,7 +160,7 @@ const { lastIssues } = await graphql(
headers: {
authorization: `token secret123`,
},
}
},
);
```
@ -220,7 +222,7 @@ const { withCustomRequest } = require("@octokit/graphql");
let requestCounter = 0;
const myRequest = request.defaults({
headers: {
authentication: "token secret123",
authorization: "bearer secret123",
},
request: {
hook(request, options) {
@ -247,13 +249,26 @@ await myGraphql(`
// requestCounter is now 2
```
## TypeScript
`@octokit/graphql` is exposing proper types for its usage with TypeScript projects.
### Additional Types
Additionally, `GraphQlQueryResponseData` has been exposed to users:
```ts
import type { GraphQlQueryResponseData } from "@octokit/graphql";
```
## Errors
In case of a GraphQL error, `error.message` is set to the first error from the responses `errors` array. All errors can be accessed at `error.errors`. `error.request` has the request options such as query, variables and headers set for easier debugging.
In case of a GraphQL error, `error.message` is set to a combined message describing all errors returned by the endpoint.
All errors can be accessed at `error.errors`. `error.request` has the request options such as query, variables and headers set for easier debugging.
```js
let { graphql } = require("@octokit/graphql");
graphqlt = graphql.defaults({
let { graphql, GraphqlResponseError } = require("@octokit/graphql");
graphql = graphql.defaults({
headers: {
authorization: `token secret123`,
},
@ -267,20 +282,30 @@ const query = `{
try {
const result = await graphql(query);
} catch (error) {
// server responds with
// {
// "data": null,
// "errors": [{
// "message": "Field 'bioHtml' doesn't exist on type 'User'",
// "locations": [{
// "line": 3,
// "column": 5
// }]
// }]
// }
if (error instanceof GraphqlResponseError) {
// do something with the error, allowing you to detect a graphql response error,
// compared to accidentally catching unrelated errors.
console.log("Request failed:", error.request); // { query, variables: {}, headers: { authorization: 'token secret123' } }
console.log(error.message); // Field 'bioHtml' doesn't exist on type 'User'
// server responds with an object like the following (as an example)
// class GraphqlResponseError {
// "headers": {
// "status": "403",
// },
// "data": null,
// "errors": [{
// "message": "Field 'bioHtml' doesn't exist on type 'User'",
// "locations": [{
// "line": 3,
// "column": 5
// }]
// }]
// }
console.log("Request failed:", error.request); // { query, variables: {}, headers: { authorization: 'token secret123' } }
console.log(error.message); // Field 'bioHtml' doesn't exist on type 'User'
} else {
// handle non-GraphQL error
}
}
```
@ -371,7 +396,7 @@ graphql("{ viewer { login } }", {
assert.strictEqual(
options.body,
'{"query":"{ viewer { login } }"}',
"Sends correct query"
"Sends correct query",
);
return { data: {} };
}),