Skip to content

Commit e69bc43

Browse files
Merge pull request #3 from Siddharth9890/develop
Feat: Release 1.0
2 parents b5f6f7a + 9d66db1 commit e69bc43

29 files changed

+3907
-1368
lines changed

.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ release.config.js
77
.husky/*
88
scripts/*
99
node_modules/*
10-
build
10+
dist
1111
test/*

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ If applicable, add screenshots to help explain your problem.
2828
- Package Manager [e.g. pnpm,npm,yarn]
2929

3030
**Additional context**
31-
Add any other context about the problem here.
31+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ A clear and concise description of what you want to happen.
1616
A clear and concise description of any alternative solutions or features you've considered.
1717

1818
**Additional context**
19-
Add any other context or screenshots about the feature request here.
19+
Add any other context or screenshots about the feature request here.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3636
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37-
run: pnpm dlx [email protected]
37+
run: pnpm dlx [email protected]

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ graphqlTypescriptTypes
44

55
coverage
66

7-
build
7+
build
8+
9+
dist

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
![](https://github.com/user-attachments/assets/6e4183f5-4432-4e20-99eb-17f2ce0e0ef7)
2+
3+
# GraphQL SDK Generator
4+
5+
The GraphQL SDK Generator converts GraphQL schemas into JavaScript or TypeScript code, enabling smooth autocomplete and validation for your GraphQL queries.
6+
7+
[![NPM version][npm-image]][npm-url]
8+
[![Run Eslint & Test cases](https://github.com/Siddharth9890/graphql-sdk-generator/actions/workflows/test.yaml/badge.svg)](https://github.com/Siddharth9890/graphql-sdk-generator/actions/workflows/test.yaml)
9+
[![Coverage Status][codecov-image]][codecov-url]
10+
11+
<!-- [![NPM downloads][downloads-image]][downloads-url] -->
12+
13+
Read this [quick start guide](https://docs.siddharth9890.com/graphql-sdk-generator) to generate your client and start writing queries
14+
15+
## Features
16+
17+
- ✅ Type completion & validation for enhanced developer experience
18+
- 🍃 Few runtime dependencies as compared to GraphQL Mesh
19+
- 🐎 Generate client only if schema changes
20+
- 🥃 Supports custom headers for requests
21+
- 🚂 Compatible with both browsers and Node.js, thanks to[graphql-request](https://www.npmjs.com/package/graphql-request)
22+
23+
## Example
24+
25+
1. Install the required package from npm globally recommended
26+
27+
```bash
28+
npm install -g graphql-sdk-generator
29+
```
30+
31+
2. Then will create a config.json file with the following contents.
32+
33+
```json
34+
{
35+
"url": "your-graphql-endpoint",
36+
"sdkName": "custom-name",
37+
"fileType": "ts",
38+
"debug": true
39+
}
40+
```
41+
42+
3. Run the generator and install additional dependencies required for making requests:
43+
44+
```bash
45+
// use a custom json file path
46+
graphql-sdk-generator -c config.json
47+
npm i @graphql-typed-document-node/core graphql-request
48+
```
49+
50+
4. Use the generated client to write methods and send data:
51+
52+
```typescript
53+
import { GraphQLClient } from 'graphql-request';
54+
import { getSdk } from '../graphqlSDKGenerator/graphqlSDKGenerator';
55+
56+
const initializeSDK = () => {
57+
// we can set custom headers
58+
const client = new GraphQLClient('https://your-graphql-url', {
59+
headers: {},
60+
});
61+
62+
return getSdk(client);
63+
};
64+
65+
const main = async () => {
66+
const sdkInstance = initializeSDK();
67+
const companies = await sdkInstance.companyQuery();
68+
69+
// we get autocomplete here both for the arguments && output.
70+
const user = await sdkInstance.insert_usersMutation({
71+
objects: { id: 1, name: 'test', rocket: 'spacex' },
72+
});
73+
74+
console.log(companies, user);
75+
};
76+
77+
main();
78+
```
79+
80+
## Docs
81+
82+
- All the documententation can be [found here.](https://docs.siddharth9890.com/graphql-sdk-generator)
83+
84+
## Example
85+
86+
- Example repo with config file examples can be [found here](https://github.com/Siddharth9890/space-x-graphql-example)
87+
88+
[Licensed under MIT]().
89+
90+
[npm-image]: https://img.shields.io/npm/v/graphql-sdk-generator
91+
[npm-url]: https://www.npmjs.com/package/graphql-sdk-generator
92+
[downloads-image]: https://img.shields.io/npm/v/graphql-sdk-generator
93+
[downloads-url]: https://www.npmjs.com/package/graphql-sdk-generator
94+
[codecov-image]: https://codecov.io/gh/Siddharth9890/graphql-sdk-generator/graph/badge.svg?token=H6ROEG8C9L
95+
[codecov-url]: https://app.codecov.io/gh/Siddharth9890/graphql-sdk-generator

docs/CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# [1.0.0-develop.5](https://github.com/Siddharth9890/graphql-sdk-generator/compare/v1.0.0-develop.4...v1.0.0-develop.5) (2024-08-31)
2+
3+
4+
### Bug Fixes
5+
6+
* modified readme, added contributing guidelines ([4c96619](https://github.com/Siddharth9890/graphql-sdk-generator/commit/4c96619667dc2650513fc0c631c8154d094c336f))
7+
8+
# [1.0.0-develop.4](https://github.com/Siddharth9890/graphql-sdk-generator/compare/v1.0.0-develop.3...v1.0.0-develop.4) (2024-08-30)
9+
10+
### Bug Fixes
11+
12+
- remove prepare command ([df96855](https://github.com/Siddharth9890/graphql-sdk-generator/commit/df96855d0860d6916a6d4857e9f9f19b20cdb3b3))
13+
14+
# [1.0.0-develop.3](https://github.com/Siddharth9890/graphql-sdk-generator/compare/v1.0.0-develop.2...v1.0.0-develop.3) (2024-08-30)
15+
16+
### Bug Fixes
17+
18+
- fixed husky error ([859489c](https://github.com/Siddharth9890/graphql-sdk-generator/commit/859489c0cd07f6c166a167378fdfc606780583e4))
19+
20+
# [1.0.0-develop.2](https://github.com/Siddharth9890/graphql-sdk-generator/compare/v1.0.0-develop.1...v1.0.0-develop.2) (2024-08-29)
21+
22+
### Features
23+
24+
- added readme, improved tests ([dcdc386](https://github.com/Siddharth9890/graphql-sdk-generator/commit/dcdc38613d37014fbe351bf2206e701065c7cf07))
25+
26+
# 1.0.0-develop.1 (2024-08-16)
27+
28+
### Features
29+
30+
- added ajv and commander ([76b94cb](https://github.com/Siddharth9890/graphql-sdk-generator/commit/76b94cb18f4417ae46655a574b6fcc66d2d0397e))
31+
- added debug mode ([ea9b844](https://github.com/Siddharth9890/graphql-sdk-generator/commit/ea9b8445295b066c6310545593a46d7e0d9d1cab))
32+
- **ci/cd:** added husky, commit lint ([c50a2dd](https://github.com/Siddharth9890/graphql-sdk-generator/commit/c50a2ddf6bbc68f128458685667fff3c9a279a2d))
33+
- inital tests ([09a1dce](https://github.com/Siddharth9890/graphql-sdk-generator/commit/09a1dce430ba38212db6ede98a27e699927526b5))
34+
- initial test code ([f33e5ea](https://github.com/Siddharth9890/graphql-sdk-generator/commit/f33e5ea48099421f8321697641caa81c4d9f592f))
35+
- jest setup and ci/cd for tests ([ef7718a](https://github.com/Siddharth9890/graphql-sdk-generator/commit/ef7718a66ce968587bdbfd5751efaca2c81d1fed))
36+
- tests are complete ([d951541](https://github.com/Siddharth9890/graphql-sdk-generator/commit/d9515413fb64c796e90ba227d6c9bd2b6155a8b1))

docs/CODE_BASE_OVERVIEW.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Code Base Overview
2+
3+
This section will give you an overview of the package codebase. We will also discuss in short the tools we use and the implementation.
4+
5+
- If you want to contribute to the package make sure you read this document and the [Contributing Guildelines](https://github.com/Siddharth9890/graphql-sdk-generator/blob/main/docs/CONTRIBUTING.md) before proceeding.
6+
7+
### Top Level Folder Structure
8+
9+
- The src folder has all the classes which a developer will use. The following are the classes which we are using:-
10+
11+
1. generateCode Folder:- Has all methods to generate types using GraphQL.
12+
13+
- The utils file has basic utilities functions like file related operations.
14+
15+
- The tests folder has all the unit test for the above classes. We are using mocking to mock the SDK.
16+
17+
- We are using prettier and eslint to make sure that code format is maintained. Across all the files.

docs/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,4 @@ enforcement ladder](https://github.com/mozilla/diversity).
124124

125125
For answers to common questions about this code of conduct, see the FAQ at
126126
https://www.contributor-covenant.org/faq. Translations are available at
127-
https://www.contributor-covenant.org/translations.
127+
https://www.contributor-covenant.org/translations.

docs/CONTRUBUTING.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
## How to contribute on package
2+
3+
### Open Development
4+
5+
- All work on the SDK happens directly on GitHub. Both core team members and external contributors send pull requests which go through the same review process.
6+
7+
### Semantic Versioning
8+
9+
- The SDK follows [semantic versioning](https://semver.org/). We release patch versions for critical bugfixes, minor versions for new features or non-essential changes, and major versions for any breaking changes.
10+
11+
- When we make breaking changes, we also introduce deprecation warnings in a minor version so that our users learn about the upcoming changes and migrate their code in advance.
12+
13+
- Every significant change is documented in the [changelog file](https://github.com/Siddharth9890/graphql-sdk-generator/blob/main/docs/CHANGELOG.md).
14+
15+
### Branch Organization
16+
17+
- Make sure to fork the repository before contributing and create the new branch using develop as the base branch.
18+
19+
- Submit all changes directly to the `develop` branch. We use separate branches for development or for upcoming releases. And then after the bug/feature is working we release in main branch.
20+
21+
- Code that lands in `develop` must be compatible with the latest stable release. It may contain additional features, but no breaking changes. We should be able to release a new minor version from the tip of develop at any time.
22+
23+
### Bugs
24+
25+
- **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead refer our [security policy](https://github.com/Siddharth9890/graphql-sdk-generator/blob/main/docs/SECURITY.md).
26+
27+
- **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/Siddharth9890/graphql-sdk-generator/issues).
28+
29+
- If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/Siddharth9890/graphql-sdk-generator/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** demonstrating the expected behavior that is not occurring.
30+
31+
- Once the issue is created you can follow the contributing steps below to start contributing
32+
33+
### **Add a new Feature**
34+
35+
- If you intend to change/add a new feature to the package please discuss with on github issues page. This lets us reach an agreement on your proposal before you put significant effort into it.
36+
37+
- Do not open an PR on GitHub until you have collected positive feedback about the feature from us.
38+
39+
- We will reject pull requests which are not discussed with us regarding feature development.
40+
41+
- Once the issue is created you can follow the contributing steps below to start contributing.
42+
43+
### Contributing Guildeline
44+
45+
- You have Node.js installed at LTS with version 18+ and using pnpm as package manager.
46+
- You have knowldge of git.
47+
- Read the [code base overview](https://github.com/Siddharth9890/graphql-sdk-generator/blob/main/docs/CODE_BASE_OVERVIEW.md) to have a short introduction about how we manage/write code.
48+
49+
### Development Workflow
50+
51+
1. After cloning the repo
52+
53+
2. Install dependencies using pnpm
54+
55+
```sh
56+
pnpm i
57+
```
58+
59+
3. Do you changes and then use dev command
60+
61+
```sh
62+
pnpm dev
63+
```
64+
65+
4. Run test command to test sdk using jest
66+
67+
```sh
68+
pnpm test
69+
```
70+
71+
- We recommend to keep test coverage above 90% this way we make sure that the feature/bug you add don't reduce the test coverage. Also make sure that there are no linting errors as we use prettier and eslint to maintain proper code structure.
72+
73+
Thanks!

0 commit comments

Comments
 (0)