@devticon-os/graphql-codegen-axios 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +79 -0
  2. package/package.json +6 -1
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ ### graphql-codegen-axios
2
+ A code generation tool that generates an Axios SDK based on your GraphQL queries. This tool makes it easy to consume GraphQL APIs in your Axios projects by automatically generating code for querying your GraphQL API and mapping the results to JavaScript objects.
3
+
4
+ ### Features
5
+ - Generates TypeScript code for querying GraphQL APIs with Axios.
6
+ - Supports the @first, @firstOrFail, and @nonNullable directives.
7
+
8
+ ### Usage
9
+ To use graphql-codegen-axios, you need to have Node.js installed on your system.
10
+
11
+ Installation
12
+ You can install graphql-codegen-axios using npm:
13
+
14
+ ```sh
15
+ npm install graphql-codegen-axios --save-dev
16
+ yarn add graphql-codegen-axios -D
17
+ pnpm add graphql-codegen-axios -D
18
+ ```
19
+ ### Configuration
20
+ In your project's codegen.yml configuration file, add the following configuration:
21
+
22
+ ```yml
23
+ overwrite: true
24
+ schema: https://your-graphql-api.com/graphql
25
+ documents: src/**/*.graphql
26
+ generates:
27
+ src/generated/graphql.ts:
28
+ plugins:
29
+ - typescript
30
+ - typescript-operations
31
+ - graphql-codegen-axios
32
+ ```
33
+ You can customize the output file path and other settings as per your requirements.
34
+
35
+ ### Directives
36
+ graphql-codegen-axios supports the following directives:
37
+
38
+ - `@first`: Returns only the first object from a collection.
39
+ - `@firstOrFail`: Returns the first object from a collection or throws an error if the collection is empty.
40
+ - `@nonNullable`: Throws an error if the query returns null.
41
+ To use a directive, add it to your GraphQL query like this:
42
+
43
+ ```graphql
44
+ query GetFirstUser {
45
+ users(first: 1) @first {
46
+ id
47
+ name
48
+ }
49
+ }
50
+ ```
51
+ ```graphql
52
+ query GetFirstUser {
53
+ users(first: 1) @firstOrFail {
54
+ id
55
+ name
56
+ }
57
+ }
58
+ ```
59
+ ```graphql
60
+ query GetFirstUser {
61
+ user(id: "1") @nonNullable {
62
+ id
63
+ name
64
+ }
65
+ }
66
+ ```
67
+ ### Generating Code
68
+ You can generate the Axios SDK by running the following command:
69
+
70
+ ```sh
71
+ npx graphql-codegen
72
+ ```
73
+ This will generate the TypeScript code in the specified output file path.
74
+
75
+ ### Contributing
76
+ Contributions are welcome! Please see the contributing guidelines for more information.
77
+
78
+ ### License
79
+ This project is licensed under the MIT License. See the LICENSE file for details.
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@devticon-os/graphql-codegen-axios",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
+ "repository": "https://github.com/devticon/graphql-codegen-axios",
7
+ "author": {
8
+ "name": "krs",
9
+ "email": "k.kamasa@gmail.com"
10
+ },
6
11
  "files": [
7
12
  "src"
8
13
  ],