Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
15,035 additions
and 0 deletions.
- +29 −0 .circleci/config.yml
- +15 −0 .editorconfig
- +17 −0 .gitignore
- +14 −0 .markdownlint.json
- +1 −0 .npmrc
- +1 −0 .nvmrc
- +28 −0 .vscode/launch.json
- +18 −0 .vscode/settings.json
- +20 −0 .vscode/tasks.json
- +21 −0 LICENSE
- +38 −0 README.md
- +5 −0 examples/1-simple-seed/.env
- +3 −0 examples/1-simple-seed/.gitignore
- +14 −0 examples/1-simple-seed/.graphqlconfig.yml
- +20 −0 examples/1-simple-seed/README.md
- +1 −0 examples/1-simple-seed/generated/index.ts
- +12 −0 examples/1-simple-seed/generated/schema.ts
- +52 −0 examples/1-simple-seed/package.json
- +23 −0 examples/1-simple-seed/src/app.ts
- +84 −0 examples/1-simple-seed/src/index.test.ts
- +16 −0 examples/1-simple-seed/src/index.ts
- +22 −0 examples/1-simple-seed/src/modules/user/user.entity.ts
- +60 −0 examples/1-simple-seed/src/modules/user/user.resolver.ts
- +56 −0 examples/1-simple-seed/tools/seed.ts
- +23 −0 examples/1-simple-seed/tsconfig.json
- +4,363 −0 examples/1-simple-seed/yarn.lock
- +3 −0 examples/README.md
- +137 −0 package.json
- +59 −0 src/core/BaseObject.ts
- +17 −0 src/core/Context.ts
- +146 −0 src/core/app.ts
- +61 −0 src/core/binding.ts
- +5 −0 src/core/index.ts
- +2 −0 src/core/logger.ts
- +20 −0 src/core/types.ts
- +20 −0 src/decorators/EmailField.ts
- +14 −0 src/decorators/EntityObject.ts
- +9 −0 src/decorators/ForeignKeyField.ts
- +40 −0 src/decorators/StringField.ts
- +4 −0 src/decorators/index.ts
- +5 −0 src/index.test.ts
- +7 −0 src/index.ts
- +45 −0 src/middleware/DataLoaderMiddleware.ts
- +30 −0 src/middleware/ErrorMiddleware.ts
- +6 −0 src/middleware/HealthMiddleware.ts
- +3 −0 src/middleware/index.ts
- +64 −0 src/schema/SchemaGenerator.ts
- +319 −0 src/schema/TypeORMConverter.ts
- +1 −0 src/schema/index.ts
- +194 −0 src/tgql/BaseResolver.ts
- +53 −0 src/tgql/BaseWhereInput.ts
- +19 −0 src/tgql/DeleteResponse.ts
- +17 −0 src/tgql/PaginationArgs.ts
- +17 −0 src/tgql/authChecker.ts
- +7 −0 src/tgql/index.ts
- +47 −0 src/torm/EverythingSubscriber.ts
- +42 −0 src/torm/SnakeNamingStrategy.ts
- +41 −0 src/torm/createConnection.ts
- +3 −0 src/torm/index.ts
- 0 src/torm/ormconfig.ts
- +9 −0 src/utils/EntityCreator.ts
- +21 −0 src/utils/decoratorComposer.ts
- +2 −0 src/utils/index.ts
- +25 −0 tsconfig.json
- +24 −0 tsconfig.test.json
- +26 −0 tslint.json
- +8,515 −0 yarn.lock
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,29 @@ | ||
version: 2 | ||
references: | ||
yarn_cache_key: &yarn_cache_key | ||
yarn-v1-{{ checksum "yarn.lock" }} | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:10.7 | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
keys: | ||
- *yarn_cache_key | ||
- yarn-v1- | ||
- run: | ||
name: dependencies | ||
command: yarn install --frozen-lockfile | ||
- run: | ||
name: build | ||
command: yarn build | ||
- run: | ||
name: test | ||
command: yarn test | ||
- run: | ||
name: deploy | ||
command: yarn run semantic-release || true | ||
- save_cache: | ||
key: *yarn_cache_key | ||
paths: ~/circleci/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
max_line_length = 120 | ||
|
||
# markdown files require trailing double whitespace for newline | ||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,14 @@ | ||
{ | ||
"MD009": { | ||
"br_spaces": 2 | ||
}, | ||
"MD013": { | ||
"code_blocks": false | ||
}, | ||
"MD026": { | ||
"punctuation": ".,;:" | ||
}, | ||
"MD029": { | ||
"style": "ordered" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,28 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Jest", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js", | ||
"stopOnEntry": false, | ||
"args": ["--runInBand", "${file}"], | ||
"cwd": "${workspaceRoot}", | ||
"protocol": "legacy", | ||
"runtimeArgs": ["--nolazy"], | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceRoot}/dist/**/*.js"] | ||
}, | ||
{ | ||
"name": "Run from index.ts", | ||
"type": "node", | ||
"request": "launch", | ||
"args": ["src/index.ts"], | ||
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"], | ||
"sourceMaps": true, | ||
"cwd": "${workspaceRoot}", | ||
"protocol": "inspector" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,18 @@ | ||
{ | ||
"prettier.printWidth": 120, | ||
"prettier.singleQuote": true, | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"search.exclude": { | ||
"dist/": true, | ||
"node_modules/": true | ||
}, | ||
"[javascript]": { | ||
"editor.formatOnSave": true | ||
}, | ||
"[json]": { | ||
"editor.formatOnSave": true | ||
}, | ||
"[typescript]": { | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,20 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"command": "source tools/environment_setup.sh", | ||
"type": "shell", | ||
"label": "setupEnvironment" | ||
}, | ||
{ | ||
"label": "build", | ||
"type": "typescript", | ||
"tsconfig": "tsconfig.json", | ||
"problemMatcher": ["$tsc"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Dan Caddigan | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,38 @@ | ||
# warthog | ||
|
||
[](https://www.npmjs.org/package/warthog) | ||
[](https://circleci.com/gh/goldcaddy77/warthog/tree/master) | ||
[](#badge) | ||
[](https://github.com/semantic-release/semantic-release) | ||
|
||
## Warthog | ||
|
||
Opinionated framework for building GraphQL APIs with strong conventions. | ||
|
||
## Install | ||
|
||
```bash | ||
yarn add warthog | ||
``` | ||
|
||
## Usage | ||
|
||
Check out the [examples folder](https://github.com/goldcaddy77/warthog/tree/v1/examples) | ||
to see how to use Warthog in a project or check out the | ||
[warthog example](https://github.com/goldcaddy77/warthog-example) project. | ||
|
||
|
||
## Contribute | ||
|
||
PRs accepted, fire away! Or add issues if you have use cases Warthog doesn't cover. | ||
|
||
## License | ||
|
||
MIT © Dan Caddigan | ||
|
||
- Apollo Server 2 (running express) | ||
- TypeORM | ||
- TypeGraphQL | ||
- GraphQL Bindings | ||
|
||
Note: requires use of Postgres currently |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,5 @@ | ||
APP_HOST=localhost | ||
APP_PORT=4100 | ||
TYPEORM_DATABASE=example1 | ||
TYPEORM_USERNAME=postgres | ||
TYPEORM_PASSWORD= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,3 @@ | ||
generated/* | ||
!generated/index.ts | ||
!generated/schema.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,14 @@ | ||
schemaPath: generated/schema.graphql | ||
extensions: | ||
endpoints: | ||
default: | ||
url: http://${env:APP_HOST}/graphql | ||
headers: | ||
Authorization: "Bearer ${env:GITHUB_TOKEN}" | ||
codegen: | ||
generator: graphql-binding | ||
language: typescript | ||
input: | ||
schema: generated/schema.js | ||
output: | ||
binding: generated/generated-binding.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,20 @@ | ||
# Example 1 - User | ||
|
||
## TLDR | ||
|
||
Run `yarn bootstrap && yarn start` | ||
|
||
## Bootstrapping the App | ||
|
||
Running `yarn bootstrap` will do the following: | ||
|
||
- Install packages | ||
- Create the example DB | ||
- Seed the database with test data | ||
|
||
## Running the App | ||
|
||
To run the project, run `yarn start`. This will: | ||
|
||
- Run the API server | ||
- Open GraphQL Playground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1 @@ | ||
export * from './classes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,12 @@ | ||
import * as fs from 'fs'; | ||
import { makeExecutableSchema } from 'graphql-tools'; | ||
import { GraphQLSchema } from 'graphql'; | ||
|
||
const schema: GraphQLSchema = makeExecutableSchema({ | ||
typeDefs: fs.readFileSync(__dirname + '/schema.graphql', 'utf-8'), | ||
resolverValidationOptions: { | ||
requireResolversForResolveType: false | ||
} | ||
}); | ||
|
||
export default schema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "example1", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"//": "make sure to install top-level packages, too", | ||
"bootstrap": "cd ../.. && yarn && cd - && yarn && yarn db:create && yarn generate:binding && yarn db:seed:dev", | ||
"db:create": "createdbjs $(dotenv -p TYPEORM_DATABASE) 2>&1 || :", | ||
"db:drop": "dropdbjs $(dotenv -p TYPEORM_DATABASE) 2>&1 || :", | ||
"db:seed:dev": "dotenv -- ts-node tools/seed.ts", | ||
"generate:binding": "yarn graphql-binding --input generated/schema.ts --language typescript --outputBinding generated/binding.ts", | ||
"playground:open": "open http://localhost:$(dotenv -p APP_PORT)/playground", | ||
"start": "npm-run-all --parallel start:ts playground:open", | ||
"start:debug": "yarn start:ts --inspect", | ||
"start:ts": "ts-node --type-check src/index.ts", | ||
"typeorm:cli": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -f ./ormconfig", | ||
"test": "dotenv -- jest", | ||
"watch:ts": "nodemon -e ts,graphql -x ts-node --type-check src/index.ts" | ||
}, | ||
"dependencies": { | ||
"pgtools": "^0.3.0", | ||
"reflect-metadata": "^0.1.12", | ||
"typescript": "^3.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.16.0", | ||
"@types/faker": "^4.1.4", | ||
"@types/isomorphic-fetch": "^0.0.34", | ||
"@types/jest": "^23.3.11", | ||
"@types/node": "^10.12.18", | ||
"dotenv-cli": "^1.4.0", | ||
"faker": "^4.1.0", | ||
"graphql-binding": "^2.3.8", | ||
"jest": "^23.6.0", | ||
"npm-run-all": "^4.1.5", | ||
"ts-jest": "^23.10.5", | ||
"ts-node": "^7.0.1" | ||
}, | ||
"jest": { | ||
"transform": { | ||
".ts": "ts-jest" | ||
}, | ||
"testRegex": "\\.test\\.ts$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"\\.test\\.ts$" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,23 @@ | ||
import 'reflect-metadata'; | ||
|
||
import { Container } from 'typedi'; | ||
import { App, AppOptions } from '../../../src/'; | ||
|
||
// import { User } from './modules/user/user.entity'; | ||
|
||
export function getApp(appOptions: Partial<AppOptions> = {}, dbOptions: any = {}) { | ||
return new App( | ||
// Path written in generated classes | ||
{ | ||
container: Container, | ||
warthogImportPath: '../../../src', | ||
...appOptions | ||
}, | ||
{ | ||
cache: true, | ||
synchronize: true, | ||
// dropSchema: true, | ||
...dbOptions | ||
} | ||
); | ||
} |
Oops, something went wrong.