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

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 +78 -0
  2. package/package.json +6 -1
package/README.md ADDED
@@ -0,0 +1,78 @@
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 @devticon-os/graphql-codegen-axios --save-dev
16
+ yarn add @devticon-os/graphql-codegen-axios -D
17
+ pnpm add @devticon-os/graphql-codegen-axios -D
18
+ ```
19
+ ### Configuration
20
+ In your project's codegen.yml configuration file, add the following configuration:
21
+
22
+ ```yml
23
+ schema: https://your-graphql-api.com/graphql
24
+ documents: src/**/*.graphql
25
+ generates:
26
+ src/generated/graphql.ts:
27
+ plugins:
28
+ - typescript
29
+ - typescript-operations
30
+ - @devticon-os/graphql-codegen-axios
31
+ ```
32
+ You can customize the output file path and other settings as per your requirements.
33
+
34
+ ### Directives
35
+ graphql-codegen-axios supports the following directives:
36
+
37
+ - `@first`: Returns only the first object from a collection.
38
+ - `@firstOrFail`: Returns the first object from a collection or throws an error if the collection is empty.
39
+ - `@nonNullable`: Throws an error if the query returns null.
40
+ To use a directive, add it to your GraphQL query like this:
41
+
42
+ ```graphql
43
+ query GetFirstUser {
44
+ users(first: 1) @first {
45
+ id
46
+ name
47
+ }
48
+ }
49
+ ```
50
+ ```graphql
51
+ query GetFirstUser {
52
+ users(first: 1) @firstOrFail {
53
+ id
54
+ name
55
+ }
56
+ }
57
+ ```
58
+ ```graphql
59
+ query GetFirstUser {
60
+ user(id: "1") @nonNullable {
61
+ id
62
+ name
63
+ }
64
+ }
65
+ ```
66
+ ### Generating Code
67
+ You can generate the Axios SDK by running the following command:
68
+
69
+ ```sh
70
+ npx graphql-codegen
71
+ ```
72
+ This will generate the TypeScript code in the specified output file path.
73
+
74
+ ### Contributing
75
+ Contributions are welcome! Please see the contributing guidelines for more information.
76
+
77
+ ### License
78
+ 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.2",
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
  ],