Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal(refactor): improving maintainability for V2 release #1400

Merged
merged 255 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
255 commits
Select commit Hold shift + click to select a range
bc69836
test: jest.config.ts compatibility and working
carlocorradini Dec 19, 2022
50d5d0f
internal(contributing): fix contributing doc headers
carlocorradini Dec 19, 2022
4dfde01
internal: fix contributing empty line
carlocorradini Dec 19, 2022
c795478
internal(paths): import can leverage paths starting with ~/ that poin…
carlocorradini Dec 19, 2022
dc18d56
internal(declarations.d.ts): removed since gulp has been removed
carlocorradini Dec 19, 2022
1bdf3b8
internal(types): types directory for reflect and type-graphql. reflec…
carlocorradini Dec 19, 2022
c5680e7
chore(cspell): added shell dictionary
carlocorradini Dec 20, 2022
cc8cac9
chore(github): added codeowners, funding and dependabot
carlocorradini Dec 20, 2022
fdd1fcc
chore(benchmarks): fix import statements
carlocorradini Dec 21, 2022
b49f250
internal: better scripting, added gitattributes and updted editorconf…
carlocorradini Dec 21, 2022
46b13a4
chore(cspell): add dict shell to cspell import
carlocorradini Dec 21, 2022
e37263e
chore(eol): force lf as end eol
carlocorradini Jan 8, 2023
d9ea9b8
Merge remote-tracking branch 'upstream/master' into maintainability
carlocorradini Feb 8, 2023
c4d70e4
fix: prettier style
carlocorradini Feb 8, 2023
6b9a014
chore(internal): fix dependencies
carlocorradini Feb 8, 2023
3e9653d
chore(fix): partial src eslint fix
carlocorradini Feb 8, 2023
5d7c958
chore(fix): partial tests eslint fix
carlocorradini Feb 8, 2023
d8152ce
chore(fix): passing check and test scripts
carlocorradini Feb 8, 2023
a2568e9
chore(scripts): added shellcheck
carlocorradini Feb 9, 2023
551b07d
Remove parcel cache from git
MichalLytek Feb 10, 2023
bd5ffb6
Change custom path from ~/ into @/
MichalLytek Feb 10, 2023
7b593cf
chore(babel): removed babel
carlocorradini Feb 10, 2023
f977b12
Use path mapping in tests
MichalLytek Feb 10, 2023
4ad2d11
Fix format issues
MichalLytek Feb 10, 2023
a88b49b
Use path mapping in tests
MichalLytek Feb 10, 2023
0928d63
Fix format issues
MichalLytek Feb 10, 2023
441ca18
Use path mapping in examples
MichalLytek Feb 10, 2023
1746377
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 10, 2023
97c0dbb
fix: prettier
carlocorradini Feb 10, 2023
2449976
fix: add npx to missing commands
carlocorradini Feb 11, 2023
3411b97
chore(ci): ci improvements
carlocorradini Feb 11, 2023
c46ea33
chore(ci): removed integration
carlocorradini Feb 12, 2023
4fb286e
chore(readme): better readme following markdownlint rules
carlocorradini Feb 12, 2023
94e0f22
chore(examples): fixed simple-usage example
carlocorradini Feb 13, 2023
288ae7d
fix: ci and add _ to simple usage example
carlocorradini Feb 13, 2023
f9cd184
chore(ci): fix ci deps install path
carlocorradini Feb 13, 2023
182ac8d
chore(deps): fix package lock
carlocorradini Feb 13, 2023
c690669
chore(ci): install not working
carlocorradini Feb 13, 2023
d05e69d
chore(ci): test npm install
carlocorradini Feb 13, 2023
74c8b59
chore(examples): fix graphql types and removed package
carlocorradini Feb 14, 2023
be42c47
chore(examples): fix using-container example
carlocorradini Feb 14, 2023
d1975e8
chore(examples): fix DI constructor
carlocorradini Feb 14, 2023
e77851d
chore(examples): fix using-scoped-container example
carlocorradini Feb 14, 2023
2a70052
chore(images): renamed img folder to images
carlocorradini Feb 14, 2023
f8d99af
fix(examples): authorization example
carlocorradini Feb 14, 2023
078c907
chore(scripts): commons must not be executable
carlocorradini Feb 14, 2023
bdae590
fix(examples): generic-types
carlocorradini Feb 14, 2023
943d97f
fix(examples); file name consistency
carlocorradini Feb 14, 2023
ffab968
fix(examples): automatic-validation
carlocorradini Feb 14, 2023
07cad7e
fix(examples): custom-validation and some typos
carlocorradini Feb 14, 2023
3eacf54
chore(cspell): sorted words
carlocorradini Feb 14, 2023
f269a49
tests: fixed some tests
carlocorradini Feb 14, 2023
b9d1774
tests: more tests fixed
carlocorradini Feb 14, 2023
7dec4fb
chore(examples): fixed enums-and-union and query-complexity examples
carlocorradini Feb 15, 2023
499e8bd
chore(package): add scripts to build benchmarks and examples
carlocorradini Feb 15, 2023
091a519
tests: fixed all tests to match current configuration
carlocorradini Feb 15, 2023
0d3b897
chore(examples): fix extensions example
carlocorradini Feb 15, 2023
9f024db
chore(examples): fix apollo-cache example
carlocorradini Feb 15, 2023
7aecbee
docs: fixed and updated authorization doc
carlocorradini Feb 15, 2023
7fa99e5
fix(docs): typo
carlocorradini Feb 15, 2023
e8c3cd0
docs: fix bootstrap doc
carlocorradini Feb 15, 2023
bf4fea3
docs: fixed and updated docs browser-usage, complexity and custom-dec…
carlocorradini Feb 15, 2023
b9fd4b6
docs: fixed and updated dependency-injection example
carlocorradini Feb 15, 2023
a247b55
chore(scripts): added check also in husky
carlocorradini Feb 15, 2023
23941c3
docs: fix and update directives doc
carlocorradini Feb 15, 2023
271dd5f
chore(dependabot): removed examples
carlocorradini Feb 16, 2023
74063f0
Add --ignore-scripts to publish command
MichalLytek Feb 17, 2023
5d41350
Fix gh action website commit message
MichalLytek Feb 17, 2023
f24176a
Move `no-console` to root benchmarks rules
MichalLytek Feb 17, 2023
9baeb44
Merge branch 'master' into maintainability
carlocorradini Feb 17, 2023
33909d9
Merge branch 'master' into maintainability
carlocorradini Feb 17, 2023
caea3c3
chore(fix): package lock
carlocorradini Feb 17, 2023
36366f3
docs: fix and updated docs
carlocorradini Feb 17, 2023
fde8fa6
docs: finished updating and fixing docs
carlocorradini Feb 19, 2023
e02ed25
chore: fix empty catch block tslint to eslint
carlocorradini Feb 19, 2023
4669ec5
docs: fix spelling and typos
carlocorradini Feb 19, 2023
9ffd9ed
tests: removed units from jest config
carlocorradini Feb 19, 2023
ff2875e
chore: import order
carlocorradini Feb 19, 2023
f4f59ea
chore(examples): added graphql-scalars example
carlocorradini Feb 20, 2023
4579811
chore: removed global require from eslint
carlocorradini Feb 21, 2023
92fc107
chore(fix): eslint rule
carlocorradini Feb 21, 2023
1f2e1ae
chore: fix eslint rule
carlocorradini Feb 22, 2023
fa74d24
chore(scripts); removed useless scripts directory and files
carlocorradini Feb 22, 2023
db89408
chore(ci): fix publish
carlocorradini Feb 23, 2023
93baf07
Fix CI names and node version
MichalLytek Feb 23, 2023
008367d
chore(fix): eslint rule
carlocorradini Feb 23, 2023
8c82f40
chore(ci): fix shellcheck
carlocorradini Feb 23, 2023
6901c3e
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 23, 2023
752d31d
chore: consistent curly and block statements eslint rule
carlocorradini Feb 23, 2023
c180570
docs: fix DI
carlocorradini Feb 23, 2023
fd4c2fe
Change workspace extension recommendation
MichalLytek Feb 23, 2023
ecf9af5
Tune eslint rules
MichalLytek Feb 23, 2023
69d00c6
Update docs readme
MichalLytek Feb 23, 2023
6348388
docs: absolute path for examples
carlocorradini Feb 23, 2023
d949a4f
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 23, 2023
fd575b0
docs: use sh instead of prisma in code block
carlocorradini Feb 23, 2023
e1f295e
Fix bootstrap docs
MichalLytek Feb 23, 2023
c63b923
docs(website): updated url to match corresponding tag
carlocorradini Feb 23, 2023
ebdc256
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 23, 2023
fc716fa
Replace prettier plugin with prettier config
MichalLytek Feb 23, 2023
b3ba8f7
docs: fixed markdownlint
carlocorradini Feb 23, 2023
3cf82bc
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 23, 2023
990b5a7
chire: moved engine and peerdeps to top
carlocorradini Feb 23, 2023
67f7b8f
chore: fix eslint
carlocorradini Feb 23, 2023
0d841f5
chore: fix eslint rule
carlocorradini Feb 23, 2023
3ff8b3e
Remove esnext.asynciterable which is part of ES2018
MichalLytek Feb 23, 2023
e973f52
chore(eslint): fix rule
carlocorradini Feb 23, 2023
bbdcafa
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Feb 23, 2023
0532363
chore: added sponsorkit, first try
carlocorradini Feb 24, 2023
be78140
chore(esm): esm and cjs support
carlocorradini Mar 1, 2023
45bf36d
chore(scripts): single script for each check in package.json
carlocorradini Mar 2, 2023
3758672
chore(sponsors): removed sponsorkit
carlocorradini Mar 4, 2023
3e7fbc8
chore: esm better
carlocorradini Mar 4, 2023
e650fa8
Merge branch 'master' into maintainability
carlocorradini Mar 7, 2023
5738efe
chore(fix): package lock
carlocorradini Mar 7, 2023
71b316d
chore: generate absolute image path in readme when publishing
carlocorradini Mar 7, 2023
3168a77
refactor: graphql errors
carlocorradini Mar 9, 2023
900216e
Merge branch 'master' into maintainability
carlocorradini Mar 27, 2023
f0bdb1a
chore(esm): better typings and esm support
carlocorradini Mar 30, 2023
81093f2
Merge branch 'master' into maintainability
carlocorradini Mar 30, 2023
ff60e81
internal(scripts): fix import assertions and dirname
carlocorradini Mar 30, 2023
7f09b29
Revert "internal(scripts): fix import assertions and dirname"
MichalLytek Mar 31, 2023
100e30d
Revert "chore(esm): better typings and esm support"
MichalLytek Mar 31, 2023
816d9ba
Add VSCode debug config for examples
MichalLytek Mar 31, 2023
9a117c5
Update deps
MichalLytek Mar 31, 2023
43f7bbd
internal(refactor): better typings in bundle
carlocorradini Mar 31, 2023
24f2bd1
chore(naming): better variables name
carlocorradini Mar 31, 2023
d324e27
chore(esm): added typescript-transformer-esm
carlocorradini Mar 31, 2023
0f58c41
chore(internal): consistent import and export
carlocorradini Apr 1, 2023
0311f03
internal(scripts): markdown images and links GitHub ref
carlocorradini Apr 5, 2023
15111ff
chore(package.json): better clean
carlocorradini Apr 5, 2023
2cc8cbc
refactor: examples with package.json
carlocorradini Apr 5, 2023
debaaba
chore(ci): example deps
carlocorradini Apr 5, 2023
15e03be
chore(ci): support node 14
carlocorradini Apr 5, 2023
81b38f3
chore(ci): fix install deps
carlocorradini Apr 5, 2023
9c0c1f5
chore(ci): should be fixed node 14
carlocorradini Apr 5, 2023
63995de
chore(package.json): prettier automation for package.json
carlocorradini Apr 6, 2023
c9702d4
docs(examples): add TSyringe example
carlocorradini Apr 6, 2023
fdcc8ef
chore(typings): add .js extension to typings
carlocorradini Apr 6, 2023
cbbe176
chore(gitignore): better gitignore
carlocorradini Apr 6, 2023
dd3b78b
Configure docusaurus version bump for new release
MichalLytek Apr 7, 2023
4f675b4
Merge branch 'master' into maintainability
carlocorradini Apr 7, 2023
1471e41
chore(package.json): order of scripts
carlocorradini Apr 7, 2023
b24129d
chore(package.json): use --message instead of -m for better readability
carlocorradini Apr 7, 2023
a13770c
wip: cts and mts
MichalLytek Apr 7, 2023
14bb239
chore(ci): install also root deps
carlocorradini Apr 7, 2023
077a8e9
Revert "wip: cts and mts"
MichalLytek Apr 7, 2023
e15b4d0
feat: version and checks
carlocorradini Apr 7, 2023
92fcd3e
internal(graphql): only check graphql version
carlocorradini Apr 7, 2023
fb3d90b
Merge branch 'master' into maintainability
carlocorradini Apr 7, 2023
04099f9
chore(scripts): add shebang ts-node
carlocorradini Apr 7, 2023
c6c5cf7
chore(examples): fixed typeorm basic usage example
carlocorradini Apr 9, 2023
506c6c1
docs: added esm example
carlocorradini Apr 11, 2023
ece0e42
chore(fix): package json lock
carlocorradini Apr 11, 2023
55c3c78
docs(examples): fixed typeorm lazy relations
carlocorradini Apr 13, 2023
8bd0f07
internal(scripts): inclusive instead of exclusive options in scripts
carlocorradini Apr 13, 2023
e8a2c6a
test: fixed eslint rule and test title
carlocorradini Apr 13, 2023
6b2983d
test: fixed conditional expect
carlocorradini Apr 14, 2023
b61b6a8
test(eslint): improving rules
carlocorradini Apr 18, 2023
c390a78
test(eslint): improving rules
carlocorradini Apr 18, 2023
fb7b583
test(eslint): improving rules
carlocorradini Apr 18, 2023
a93870f
test(eslint): fixed eslint and improving rules
carlocorradini Apr 18, 2023
bd36858
chore(eslint): fixed no-prototype-builtins eslint rule
carlocorradini Apr 18, 2023
6e6d677
chore(eslint): ignored eslint rule no-await-in-loop
carlocorradini Apr 18, 2023
24a21f3
chore(eslint): fixed additional eslint rules
carlocorradini Apr 18, 2023
436f8ae
Merge branch 'master' into 'maintainability'
carlocorradini Apr 18, 2023
15956bb
chore(eslint): fix prefer-spread
carlocorradini Apr 18, 2023
6566272
chore(eslint): fixed rules no-restricted-syntax and vars-on-top
carlocorradini Apr 18, 2023
c018b32
chore(eslint): fixed rules @typescript-eslint/no-var-requires and par…
carlocorradini Apr 18, 2023
f1a3629
chore(eslint): fix rules import/no-cycle and @typescript-eslint/no-no…
carlocorradini Apr 19, 2023
83ce5fa
chore(typescript): strict typescript
carlocorradini Apr 19, 2023
aacb3f1
chore(ci): added npm package provenance
carlocorradini Apr 23, 2023
6a63428
Merge branch 'master' into maintainability
carlocorradini Apr 26, 2023
7a93ec5
[WIP] Configure npm workspace to hoist deps
MichalLytek Apr 28, 2023
8402dfb
refactor(internal): npm workspaces
carlocorradini May 3, 2023
4c7735c
change build config to ES2021
MichalLytek May 3, 2023
071833e
change build config to ES2021
MichalLytek May 3, 2023
3fe0feb
chore(eslint): removed extends
carlocorradini May 3, 2023
6d8969b
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini May 3, 2023
b43760e
chore(ci): codeql
carlocorradini May 3, 2023
5a68874
chore(package): included website and fix ci and dependabot
carlocorradini May 4, 2023
24f7677
fix: revert Class to ClassType
carlocorradini May 4, 2023
cc79ebd
fix: ClassType in examples
carlocorradini May 4, 2023
5c3b0a7
test: fix class type
carlocorradini May 4, 2023
e4a71c0
Merge branch 'master' into maintainability
carlocorradini May 5, 2023
da60b5b
Upgrade lockfile
MichalLytek May 5, 2023
e3e44d7
Fix glob import in markdown script
MichalLytek May 5, 2023
d531829
Fix release script to work with npm workspaces
MichalLytek May 5, 2023
b312c75
chore(vscode): github action extension
carlocorradini May 5, 2023
14590bd
[WIP] revert npm workspaces
MichalLytek May 20, 2023
a19c363
Merge branch 'master' into 'maintainability'
carlocorradini May 24, 2023
706c941
chore(structure): towards merge
carlocorradini May 28, 2023
e16e882
docs(examples): fixed esm examples
carlocorradini May 30, 2023
bf4e0cf
Merge branch 'master' into maintainability
carlocorradini Jun 2, 2023
8e02168
Merge branch 'master' into pr/carlocorradini/1400
MichalLytek Jun 7, 2023
00afaf6
chore(ci): Node.js 20
carlocorradini Jun 11, 2023
78abb31
chore(ci): use 18.x in steps
carlocorradini Jun 11, 2023
9b1b7bb
Misc fixes
MichalLytek Jun 14, 2023
17a2002
Remove format package json
MichalLytek Jun 14, 2023
c232e5f
Add check tests script
MichalLytek Jun 21, 2023
022f11b
Adjust .env files
MichalLytek Jun 21, 2023
7153695
Adjust typegoose example
MichalLytek Jun 21, 2023
e50b7e1
Adjust simple-subscriptions example
MichalLytek Jun 21, 2023
eeb830d
Merge branch 'master' into pr/carlocorradini/1400
MichalLytek Jun 21, 2023
fd63b49
Merge branch 'master' into maintainability
carlocorradini Jun 24, 2023
b995100
docs(examples): fix typegoose example
carlocorradini Jun 24, 2023
64484a2
docs(examples): fix simple-subscriptions example
carlocorradini Jun 25, 2023
c2d04b1
docs(examples): fix redis-subscriptions example
carlocorradini Jun 25, 2023
363b671
Merge branch 'master' into maintainability
carlocorradini Jun 25, 2023
0ca74e0
docs(examples): rename rate to rating
carlocorradini Jun 25, 2023
08bdaeb
docs(examples): fix mikro-orm example
carlocorradini Jun 25, 2023
7b577a6
Adjust redis-subscriptions example
MichalLytek Jun 22, 2023
d8d7810
Adjust mixins and inheritance examples
MichalLytek Jun 26, 2023
9d98566
Adjust lint issues
MichalLytek Jun 26, 2023
cc4c989
Fix bootstrap error catch in examples
MichalLytek Jun 26, 2023
ead06da
Adjust middlewares example
MichalLytek Jun 26, 2023
5dcef4e
Adjust interfaces example
MichalLytek Jun 26, 2023
18048a4
Adjust federation example
MichalLytek Jun 26, 2023
6f223ec
Fix graphql schema file emitting in examples/docs/tests
MichalLytek Jun 26, 2023
7a323a3
Merge branch 'master' into maintainability
carlocorradini Jul 1, 2023
af74a52
Merge branch 'maintainability' of https://github.com/carlocorradini/t…
carlocorradini Jul 1, 2023
47d491a
docs(examples): adjust syntax of mixin example
carlocorradini Jul 1, 2023
8255221
docs(examples): adjust syntax of resolver-inheritance example
carlocorradini Jul 1, 2023
0b5100b
docs(examples): adjust syntax of middlewares example
carlocorradini Jul 2, 2023
e8a7f6e
docs(examples): adjust syntax of interfaces example
carlocorradini Jul 2, 2023
350c0f7
docs(examples): adjust syntax of apollo-federation example
carlocorradini Jul 2, 2023
ff0638a
docs(examples): adjust node import
carlocorradini Jul 2, 2023
b805889
Merge branch 'master' into maintainability
carlocorradini Jul 5, 2023
ba2b534
Merge branch 'master' into maintainability
carlocorradini Jul 9, 2023
7945647
chore(deps): updated deps and corresponding files
carlocorradini Jul 9, 2023
2add8ef
docs(examples): added type module for esm example
carlocorradini Jul 9, 2023
fb543cc
Remove Apollo Client local state example
MichalLytek Jul 12, 2023
4505870
Update ignore files and fix lint config
MichalLytek Jul 12, 2023
8400666
Remove build examples scripts
MichalLytek Jul 12, 2023
6e674a4
Fix esm example tsconfig
MichalLytek Jul 12, 2023
8daf5d3
Fix check package.json script
MichalLytek Jul 12, 2023
84dea54
Remove esm example
MichalLytek Jul 19, 2023
0f87872
Add info about ESM support in docs
MichalLytek Jul 19, 2023
bca7e56
Bump dependencies
MichalLytek Jul 24, 2023
f745a86
chore: fix eslint and typos
carlocorradini Jul 24, 2023
c615b95
chore(ci): fix workspace with prefix
carlocorradini Jul 24, 2023
1417617
chore(eslint): fix typescript eslint rules
carlocorradini Jul 25, 2023
70b4df8
Configure imports and definitions eslint rules
MichalLytek Aug 2, 2023
a0facce
chore(ci): more robust regex
carlocorradini Aug 2, 2023
0517070
chore(metadata): global declaration in source
carlocorradini Aug 3, 2023
78c5e9f
chore(ci): fix semver comparison result
carlocorradini Aug 3, 2023
aed613e
Merge branch 'master' into maintainability
Aug 3, 2023
420bf1b
Properly configure lint staged
MichalLytek Aug 9, 2023
7e546d9
Fix import/no-cycle
MichalLytek Aug 9, 2023
b4c9dfd
Improve directives docs
MichalLytek Aug 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: added esm example
  • Loading branch information
carlocorradini committed Apr 11, 2023
commit 506c6c13f769fb57f9819908d3b3b954b83da3aa
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"tests/tsconfig.json",
"scripts/tsconfig.json",
"examples/tsconfig.json",
"examples/tsconfig.esm.json",
"benchmarks/tsconfig.json"
],
"ecmaVersion": "latest",
Expand All @@ -28,6 +29,7 @@
"tests/tsconfig.json",
"scripts/tsconfig.json",
"examples/tsconfig.json",
"examples/tsconfig.esm.json",
"benchmarks/tsconfig.json"
]
}
Expand Down
1 change: 1 addition & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All examples have an `examples.graphql` file with sample queries/mutations/subsc
## Basics

- [Simple usage of fields, basic types and resolvers](https://github.com/MichalLytek/type-graphql/tree/master/examples/simple-usage)
- [ECMAScript modules (ESM)](https://github.com/MichalLytek/type-graphql/tree/master/examples/esm)

## Advanced

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All examples have an `examples.graphql` file with sample queries/mutations/subsc
## Basics

- [Simple usage of fields, basic types and resolvers](./simple-usage)
- [ECMAScript modules (ESM)](./esm)

## Advanced

Expand Down
25 changes: 25 additions & 0 deletions examples/esm/examples.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
query GetRecipe1 {
recipe(title: "Recipe 1") {
title
description
ratings
creationDate
ratingsCount(minRate: 2)
averageRating
}
}

query GetRecipes {
recipes {
title
description
creationDate
averageRating
}
}

mutation AddRecipe {
addRecipe(recipe: { title: "New recipe", description: "Simple description" }) {
creationDate
}
}
22 changes: 22 additions & 0 deletions examples/esm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "reflect-metadata";
import path from "node:path";
import url from "node:url";
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { buildSchema } from "type-graphql";
import { RecipeResolver } from "./recipe.resolver.js";

// Build TypeGraphQL executable schema
const schema = await buildSchema({
// Array of resolvers
resolvers: [RecipeResolver],
// Create 'schema.graphql' file with schema definition in current directory
emitSchemaFile: path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "schema.graphql"),
carlocorradini marked this conversation as resolved.
Show resolved Hide resolved
});

// Create GraphQL server
const server = new ApolloServer({ schema });

// Start server
const { url: serverURL } = await startStandaloneServer(server, { listen: { port: 4000 } });
console.log(`GraphQL server ready at ${serverURL}`);
3 changes: 3 additions & 0 deletions examples/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
28 changes: 28 additions & 0 deletions examples/esm/recipe.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Recipe } from "./recipe.type.js";

function createRecipe(recipeData: Partial<Recipe>) {
return Object.assign(new Recipe(), recipeData);
}

export function createRecipeSamples() {
return [
createRecipe({
description: "Desc 1",
title: "Recipe 1",
ratings: [0, 3, 1],
creationDate: new Date("2018-04-11"),
}),
createRecipe({
description: "Desc 2",
title: "Recipe 2",
ratings: [4, 2, 3, 1],
creationDate: new Date("2018-04-15"),
}),
createRecipe({
description: "Desc 3",
title: "Recipe 3",
ratings: [5, 4],
creationDate: new Date(),
}),
];
}
11 changes: 11 additions & 0 deletions examples/esm/recipe.input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Field, InputType } from "type-graphql";
import type { Recipe } from "./recipe.type.js";

@InputType()
export class RecipeInput implements Partial<Recipe> {
@Field()
title: string;

@Field({ nullable: true })
description?: string;
}
41 changes: 41 additions & 0 deletions examples/esm/recipe.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { ResolverInterface } from "type-graphql";
import { Arg, FieldResolver, Int, Mutation, Query, Resolver, Root } from "type-graphql";
import { createRecipeSamples } from "./recipe.data.js";
import { RecipeInput } from "./recipe.input.js";
import { Recipe } from "./recipe.type.js";

@Resolver(_of => Recipe)
export class RecipeResolver implements ResolverInterface<Recipe> {
private readonly items: Recipe[] = createRecipeSamples();

@Query(_returns => Recipe, { nullable: true })
async recipe(@Arg("title") title: string): Promise<Recipe | undefined> {
return this.items.find(recipe => recipe.title === title);
}

@Query(_returns => [Recipe], { description: "Get all the recipes from around the world " })
async recipes(): Promise<Recipe[]> {
return this.items;
}

@Mutation(_returns => Recipe)
async addRecipe(@Arg("recipe") recipeInput: RecipeInput): Promise<Recipe> {
const recipe = Object.assign(new Recipe(), {
description: recipeInput.description,
title: recipeInput.title,
ratings: [],
creationDate: new Date(),
});
await this.items.push(recipe);

return recipe;
}

@FieldResolver()
ratingsCount(
@Root() recipe: Recipe,
@Arg("minRate", _type => Int, { defaultValue: 0 }) minRate: number,
): number {
return recipe.ratings.filter(rating => rating >= minRate).length;
}
}
35 changes: 35 additions & 0 deletions examples/esm/recipe.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Field, Float, Int, ObjectType } from "type-graphql";

@ObjectType({ description: "Object representing cooking recipe" })
export class Recipe {
@Field()
title: string;

@Field(_type => String, { nullable: true, deprecationReason: "Use 'description' field instead" })
get specification(): string | undefined {
return this.description;
}

@Field({ nullable: true, description: "The recipe description with preparation info" })
description?: string;

@Field(_type => [Int])
ratings: number[];

@Field()
creationDate: Date;

@Field(_type => Int)
ratingsCount: number;

@Field(_type => Float, { nullable: true })
get averageRating(): number | null {
const ratingsCount = this.ratings.length;
if (ratingsCount === 0) {
return null;
}
const ratingsSum = this.ratings.reduce((a, b) => a + b, 0);

return ratingsSum / ratingsCount;
}
}
44 changes: 44 additions & 0 deletions examples/esm/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -----------------------------------------------
# !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!!
# !!! DO NOT MODIFY THIS FILE BY YOURSELF !!!
# -----------------------------------------------

"""
The javascript `Date` as string. Type represents date and time as the ISO Date string.
"""
scalar DateTime

type Mutation {
addRecipe(recipe: RecipeInput!): Recipe!
}

type Query {
recipe(title: String!): Recipe

"""
Get all the recipes from around the world
"""
recipes: [Recipe!]!
}

"""
Object representing cooking recipe
"""
type Recipe {
averageRating: Float
creationDate: DateTime!

"""
The recipe description with preparation info
"""
description: String
ratings: [Int!]!
ratingsCount(minRate: Int = 0): Int!
specification: String @deprecated(reason: "Use `description` field instead")
title: String!
}

input RecipeInput {
description: String
title: String!
}
2 changes: 2 additions & 0 deletions examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"private": true,
"scripts": {
"prebuild": "npm run --prefix ../ build && npm run clean",
"build": "npx tsc --build ./tsconfig.json",
"clean": "npx shx rm -rf build"
"build": "npx tsc --build ./tsconfig.json ./tsconfig.esm.json",
"postbuild": "npx ts-node ../scripts/package.json.ts --skip-root",
"clean": "npx shx rm -rf ./build"
},
"dependencies": {
"@apollo/cache-control-types": "^1.0.2",
Expand Down
5 changes: 5 additions & 0 deletions examples/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"compilerOptions": { "module": "esnext" },
"include": ["./esm"]
}
2 changes: 1 addition & 1 deletion examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": { "outDir": "./build", "paths": {} },
"compilerOptions": { "outDir": "./build", "rootDir": ".", "paths": {} },
"include": [
"./apollo-cache",
"./authorization",
Expand Down
60 changes: 21 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading