@drupal-api-client/graphql-client 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +9 -0
- package/README.md +9 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +7 -0
- package/dist/index.mjs +5 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Drupal API Client.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# decoupled-router-client
|
2
|
+
|
3
|
+
This package contains the `GraphqlClient` class which extends the base `ApiClient` class from the `@drupal-api-client/api-client` package. See https://www.drupal.org/project/api_client for more information about this project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```shell
|
8
|
+
npm install @drupal-api-client/graphql-client
|
9
|
+
```
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ApiClient, BaseUrl, ApiClientOptions } from '@drupal-api-client/api-client';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Graphql Client class provides functionality specific to GraphQL servers.
|
5
|
+
* @see {@link ApiClientOptions}
|
6
|
+
* @see {@link BaseUrl}
|
7
|
+
*/
|
8
|
+
declare class GraphqlClient extends ApiClient {
|
9
|
+
/**
|
10
|
+
* Creates a new instance of the GraphqlClient.
|
11
|
+
* @param baseUrl - The base URL of the API. {@link BaseUrl}
|
12
|
+
* @param options - (Optional) Additional options for configuring the API client. {@link ApiClientOptions}
|
13
|
+
*/
|
14
|
+
constructor(baseUrl: BaseUrl, options?: ApiClientOptions);
|
15
|
+
/**
|
16
|
+
* Retrieves data of a specific shape from GraphQL.
|
17
|
+
* @param query - a string containing the desired GraphQL Query.
|
18
|
+
* @returns A Promise that resolves to the requested JSON data.
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```ts
|
22
|
+
* const query = await graphqlClient.query(
|
23
|
+
* `query GetArticles {
|
24
|
+
* nodeArticles(first: 10) {
|
25
|
+
* nodes {
|
26
|
+
* title
|
27
|
+
* }
|
28
|
+
* }
|
29
|
+
* }`,
|
30
|
+
* );
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
query<T>(query: string): Promise<T>;
|
34
|
+
}
|
35
|
+
|
36
|
+
export { GraphqlClient };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ApiClient, BaseUrl, ApiClientOptions } from '@drupal-api-client/api-client';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Graphql Client class provides functionality specific to GraphQL servers.
|
5
|
+
* @see {@link ApiClientOptions}
|
6
|
+
* @see {@link BaseUrl}
|
7
|
+
*/
|
8
|
+
declare class GraphqlClient extends ApiClient {
|
9
|
+
/**
|
10
|
+
* Creates a new instance of the GraphqlClient.
|
11
|
+
* @param baseUrl - The base URL of the API. {@link BaseUrl}
|
12
|
+
* @param options - (Optional) Additional options for configuring the API client. {@link ApiClientOptions}
|
13
|
+
*/
|
14
|
+
constructor(baseUrl: BaseUrl, options?: ApiClientOptions);
|
15
|
+
/**
|
16
|
+
* Retrieves data of a specific shape from GraphQL.
|
17
|
+
* @param query - a string containing the desired GraphQL Query.
|
18
|
+
* @returns A Promise that resolves to the requested JSON data.
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```ts
|
22
|
+
* const query = await graphqlClient.query(
|
23
|
+
* `query GetArticles {
|
24
|
+
* nodeArticles(first: 10) {
|
25
|
+
* nodes {
|
26
|
+
* title
|
27
|
+
* }
|
28
|
+
* }
|
29
|
+
* }`,
|
30
|
+
* );
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
query<T>(query: string): Promise<T>;
|
34
|
+
}
|
35
|
+
|
36
|
+
export { GraphqlClient };
|
package/dist/index.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var apiClient = require('@drupal-api-client/api-client');
|
4
|
+
|
5
|
+
var t=class extends apiClient.ApiClient{constructor(s,e){super(s,e);let{apiPrefix:r}=e||{};this.apiPrefix=r||"graphql";}async query(s){let{response:e,error:r}=await this.fetch(`${this.baseUrl}/${this.apiPrefix}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`${s}`})});if(r)throw this.debug&&this.log("error",`GraphQL query failed, Error: ${r.message}`),r;return await e.json()}};
|
6
|
+
|
7
|
+
exports.GraphqlClient = t;
|
package/dist/index.mjs
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
import { ApiClient } from '@drupal-api-client/api-client';
|
2
|
+
|
3
|
+
var t=class extends ApiClient{constructor(s,e){super(s,e);let{apiPrefix:r}=e||{};this.apiPrefix=r||"graphql";}async query(s){let{response:e,error:r}=await this.fetch(`${this.baseUrl}/${this.apiPrefix}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`${s}`})});if(r)throw this.debug&&this.log("error",`GraphQL query failed, Error: ${r.message}`),r;return await e.json()}};
|
4
|
+
|
5
|
+
export { t as GraphqlClient };
|
package/package.json
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
{
|
2
|
+
"name": "@drupal-api-client/graphql-client",
|
3
|
+
"version": "0.1.3",
|
4
|
+
"license": "MIT",
|
5
|
+
"description": "Client to simplify interacting with Drupal GraphQL APIs",
|
6
|
+
"bugs": "https://www.drupal.org/project/issues/api_client",
|
7
|
+
"repository": {
|
8
|
+
"type": "git",
|
9
|
+
"url": "https://git.drupalcode.org/project/api_client.git",
|
10
|
+
"directory": "packages/graphql-client"
|
11
|
+
},
|
12
|
+
"homepage": "https://project.pages.drupalcode.org/api_client/",
|
13
|
+
"keywords": [
|
14
|
+
"drupal",
|
15
|
+
"graphql"
|
16
|
+
],
|
17
|
+
"files": [
|
18
|
+
"dist/*"
|
19
|
+
],
|
20
|
+
"types": "./dist/index.d.ts",
|
21
|
+
"main": "./dist/index.js",
|
22
|
+
"module": "./dist/index.mjs",
|
23
|
+
"exports": {
|
24
|
+
".": {
|
25
|
+
"import": {
|
26
|
+
"types": "./dist/index.d.mts",
|
27
|
+
"default": "./dist/index.mjs"
|
28
|
+
},
|
29
|
+
"require": {
|
30
|
+
"types": "./dist/index.d.ts",
|
31
|
+
"default": "./dist/index.js"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"@arethetypeswrong/cli": "^0.13.1",
|
37
|
+
"@vitest/coverage-v8": "^0.34.1",
|
38
|
+
"publint": "^0.2.0",
|
39
|
+
"tsup": "^7.3.0",
|
40
|
+
"vitest": "^0.34.6"
|
41
|
+
},
|
42
|
+
"typedocOptions": {
|
43
|
+
"entryPoints": [
|
44
|
+
"src/index.ts"
|
45
|
+
],
|
46
|
+
"tsconfig": "./tsconfig.typedoc.json"
|
47
|
+
},
|
48
|
+
"dependencies": {
|
49
|
+
"msw": "2.0.8",
|
50
|
+
"nanostores": "^0.10.2",
|
51
|
+
"@drupal-api-client/api-client": "1.3.0"
|
52
|
+
},
|
53
|
+
"scripts": {
|
54
|
+
"arethetypeswrong": "pnpm attw --pack .",
|
55
|
+
"check:types": "pnpm arethetypeswrong && pnpm publint",
|
56
|
+
"build": "tsup src/index.ts",
|
57
|
+
"test": "vitest run --coverage",
|
58
|
+
"prettier": "prettier --check . --ignore-path ../../.prettierignore",
|
59
|
+
"prettier:fix": "prettier --check . --ignore-path ../../.prettierignore",
|
60
|
+
"eslint": "eslint --ext .ts src --ignore-path ../../.gitignore",
|
61
|
+
"eslint:fix": "eslint --ext .ts src --ignore-path ../../.gitignore --fix"
|
62
|
+
}
|
63
|
+
}
|