Skip to content

Commit d22f10b

Browse files
author
rickschubert
committed
Initial commit
0 parents  commit d22f10b

17 files changed

+8056
-0
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
coverage/

.eslintrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"extends": "rickschubert",
3+
"root": true,
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 6,
7+
"sourceType": "module",
8+
"ecmaFeatures": {
9+
"modules": true
10+
}
11+
},
12+
"plugins": ["@typescript-eslint", "jest"],
13+
"settings": {
14+
"import/resolver": {
15+
"node": {
16+
"extensions": [".js"],
17+
"paths": ["."]
18+
}
19+
}
20+
},
21+
"env": {
22+
"jest/globals": true
23+
},
24+
"rules": {
25+
"no-console": "error"
26+
}
27+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
coverage/

.huskyrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "lint-staged"
4+
}
5+
}

.lintstagedrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"*.{ts,tsx}": [
3+
"prettier --write",
4+
"eslint --fix",
5+
"git add"
6+
],
7+
"*.{json}": [
8+
"prettier --write",
9+
"git add"
10+
]
11+
}

.npmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
node_modules/
2+
src/
3+
coverage/
4+
dist/test/
5+
tsconfig.json
6+
.gitignore
7+
.prettierignore
8+
prettier.config.js
9+
.env
10+
.eslintrc
11+
.eslintignore
12+
.huskyrc
13+
.lintstagedrc
14+
**/*.ts
15+
!**/*.d.ts
16+
release.sh
17+
.vscode/
18+
.npm/
19+
.npmrc
20+
.npmignore

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
node_modules/
3+
dist/

.vscode/launch.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Jest - run tests and set breakpoints. Change the args property to only run individual tests.",
8+
"program": "${workspaceFolder}/node_modules/.bin/jest",
9+
"args": ["--runInBand", "dist"],
10+
"console": "integratedTerminal",
11+
"internalConsoleOptions": "neverOpen",
12+
"disableOptimisticBPs": true,
13+
"windows": {
14+
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
15+
}
16+
}
17+
]
18+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 tray.io
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
graphql-query-to-json
2+
=====================
3+
4+
This is a simple module that takes a graphQL query string and converts it into a JSON object. Think of it as the reverse of the excellent module [json-to-graphql-query](https://www.npmjs.com/package/json-to-graphql-query).
5+
6+
## Installation
7+
8+
```sh
9+
npm install graphql-query-to-json
10+
# or
11+
yarn add graphql-query-to-json
12+
```
13+
14+
## Usage
15+
16+
```ts
17+
const {graphQlQueryToJson} = require("graphql-query-to-json")
18+
19+
const query = `
20+
query GetThisStuff($name: String, $lastName: String) {
21+
viewer {
22+
personal(criteria: {
23+
name: $name,
24+
lastName: $lastName
25+
}) {
26+
name
27+
address
28+
}
29+
}
30+
}
31+
`
32+
const result = graphQlQueryToJson(query, {
33+
variables: {
34+
name: "PETER",
35+
lastName: "SCHMIDT",
36+
},
37+
})
38+
expect(result).toEqual({
39+
query: {
40+
viewer: {
41+
personal: {
42+
__args: {
43+
criteria: {
44+
name: "PETER",
45+
lastName: "SCHMIDT",
46+
},
47+
},
48+
name: true,
49+
address: true,
50+
},
51+
},
52+
},
53+
})
54+
```
55+
56+
# Debugging
57+
Run the VSCode configuration "Jest" and set a breakpoint in the code wherever you feel the need to inspect.

0 commit comments

Comments
 (0)