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

Development #26

Open
wants to merge 275 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
275 commits
Select commit Hold shift + click to select a range
f8ad431
feat: new types
osher-sade Mar 4, 2020
2895af9
Merge remote-tracking branch 'origin/development' into development
osher-sade Mar 4, 2020
3ce5a9e
chore(release): 2.0.0-beta.1 [skip ci]
semantic-release-bot Mar 4, 2020
a6da83f
fix: disabled playground when environment is set to prod
osher-sade Mar 5, 2020
8b63e8e
style: prettified files
osher-sade Mar 5, 2020
2dc9a24
Merge pull request #29 from Enigmatis/disable-playground-in-prod
chenshoo Mar 8, 2020
35b9063
chore(release): 2.0.0-beta.2 [skip ci]
semantic-release-bot Mar 8, 2020
587a4c4
fix: updated dependencies
osher-sade Mar 9, 2020
13219cc
fix(package): update dependencies
osher-sade Mar 9, 2020
aabed46
fix(package): update dependencies
osher-sade Mar 9, 2020
387137a
Merge pull request #30 from Enigmatis/fix-irrelevant-entities
osher-sade Mar 9, 2020
a75ac22
chore(release): 2.0.0-beta.3 [skip ci]
semantic-release-bot Mar 9, 2020
8798dba
fix(directives): polaris server now creates a schema with directives
osher-sade Mar 10, 2020
436c8ee
refactor(package-lock): updated package-lock.json
osher-sade Mar 11, 2020
3f0edf6
fix(subscription): subscription context fix
osher-sade Mar 15, 2020
c6fe450
test(subscription): added subscription test
osher-sade Mar 16, 2020
839b235
docs(subscription): added subscription doc
osher-sade Mar 16, 2020
5c20805
Merge pull request #31 from Enigmatis/subscription-tests-and-doc
osher-sade Mar 17, 2020
d633e66
chore(release): 2.0.0-beta.4 [skip ci]
semantic-release-bot Mar 17, 2020
e3d52c8
feat(warnings): add warnings to extensions.
itaykl Mar 17, 2020
4ce390a
feat(warnings): add warnings to extensions.
itaykl Mar 18, 2020
65e22f6
Merge remote-tracking branch 'origin/development' into add-warnings-t…
itaykl Mar 18, 2020
692b3ca
refactor: audit fix.
itaykl Mar 18, 2020
6d020c1
feat(headers): added mandatory headers feature
osher-sade Mar 18, 2020
9ac1ae3
refactor: fix code review comments.
itaykl Mar 18, 2020
6c7ab87
refactor: fix code review comments.
itaykl Mar 18, 2020
c23b416
Merge remote-tracking branch 'origin/add-warnings-to-extensions' into…
osher-sade Mar 18, 2020
f2bc136
refactor: solved conflicts
osher-sade Mar 18, 2020
c411ce5
docs: added mandatory headers doc
osher-sade Mar 18, 2020
7c77de5
test: refactored all unit and integration test locations
osher-sade Mar 18, 2020
06e4089
test: refactored all unit and integration test locations
osher-sade Mar 18, 2020
952ee94
test: refactored all unit and integration test locations
osher-sade Mar 18, 2020
baf41d5
fix(custom-context): replace deep merge with lodash.merge and add tests
Mar 18, 2020
7b8091b
fix(ci): restored dotenv in package-lock.json
Mar 18, 2020
62dd909
refactor: fix tests failed.
itaykl Mar 19, 2020
6ffdda4
Merge pull request #32 from Enigmatis/add-warnings-to-extensions
itaykl Mar 19, 2020
584a079
test: refactored all unit and integration test locations
osher-sade Mar 19, 2020
7e33ac0
Merge remote-tracking branch 'origin/development' into mandatory-headers
osher-sade Mar 19, 2020
ef92c83
chore(release): 2.0.0-beta.5 [skip ci]
semantic-release-bot Mar 19, 2020
2da1ebc
test: refactored all unit and integration test locations
osher-sade Mar 19, 2020
a511961
Merge remote-tracking branch 'origin/mandatory-headers' into fix/inst…
Mar 19, 2020
f9f831b
fix(ci): apply changes after merge of mandatory-headers branch
Mar 19, 2020
1776e41
fix(prettier): prettier on my json files ey boss
Mar 19, 2020
c2b940d
Merge pull request #34 from Enigmatis/mandatory-headers
osher-sade Mar 19, 2020
c78ea1b
chore(release): 2.0.0-beta.6 [skip ci]
semantic-release-bot Mar 19, 2020
5431f1d
Merge remote-tracking branch 'origin/development' into support-direct…
osher-sade Mar 19, 2020
64e7da6
refactor: fixed dependency issues
osher-sade Mar 19, 2020
febabcf
test: added directives tests
osher-sade Mar 19, 2020
9661877
test: added directives tests
osher-sade Mar 19, 2020
34641e8
feat: added whoami endpoint
osher-sade Mar 19, 2020
9c22886
test: added whoami tests
osher-sade Mar 19, 2020
0fe92be
fix(cr): resolved comments from cr
Mar 19, 2020
a84f4f2
fix(cr): resolved comments from cr
Mar 19, 2020
13e85ea
Merge pull request #35 from Enigmatis/fix/instance-in-custom-context
carmi2214 Mar 19, 2020
0c54851
chore(release): 2.0.0-beta.7 [skip ci]
semantic-release-bot Mar 19, 2020
89220a1
Merge pull request #36 from Enigmatis/support-directives
osher-sade Mar 22, 2020
da752ae
Merge pull request #37 from Enigmatis/whoami-endpoint
osher-sade Mar 22, 2020
dca33c7
chore(release): 2.0.0-beta.8 [skip ci]
semantic-release-bot Mar 22, 2020
1a08f7a
feat: exported express app for custom endpoints
osher-sade Mar 22, 2020
e772fb2
refactor: exported express app for custom endpoints
osher-sade Mar 22, 2020
d3af1c5
Merge pull request #38 from Enigmatis/export-express-app
osher-sade Mar 22, 2020
94a868c
chore(release): 2.0.0-beta.9 [skip ci]
semantic-release-bot Mar 22, 2020
6717735
fix: plugins
DoctorVoid Mar 24, 2020
7f0f006
feat(transactionalMutations): temp commit - not finished yet.
itaykl Mar 25, 2020
b3ea012
fix: pagination plugin
DoctorVoid Mar 25, 2020
7fdfc3d
fix: pagination
DoctorVoid Mar 25, 2020
6bac41b
fix: fixed stuff
DoctorVoid Mar 25, 2020
cb99e90
fix: kinda working
DoctorVoid Mar 26, 2020
dbdc6f3
refactor: wip snapshot paging
osher-sade Mar 26, 2020
33b4f1f
refactor: wip snapshot paging
osher-sade Mar 26, 2020
83d1412
refactor: wip snapshot paging
osher-sade Mar 26, 2020
a7c0f1a
refactor: renamed to snapshot plugin
osher-sade Mar 26, 2020
e3294bd
fix: added snapshot configuration
DoctorVoid Mar 26, 2020
e027891
refactor: updated dependencies
osher-sade Mar 29, 2020
5303e91
refactor: updated dependencies
osher-sade Mar 29, 2020
aeadde3
style: prettify code
osher-sade Mar 29, 2020
7fa94cc
feat(transactional mutations): not finished yet at all.
itaykl Mar 29, 2020
2618252
fix: started doing stuff
DoctorVoid Mar 29, 2020
b297f8f
feat(transactional mutations): not finished yet at all.
itaykl Mar 30, 2020
0eda19b
fix: pagination works kinda!
DoctorVoid Mar 30, 2020
98a8bdf
fix: count per page can not be bigger than configured max page size
osher-sade Mar 31, 2020
f9ed73c
feat(transactional mutations): temp commit, finished tests but maybe …
itaykl Mar 31, 2020
2aa5b82
fix: fixed plugins that were sent in a snap request
osher-sade Mar 31, 2020
f9857b7
refactor: code review fixes
osher-sade Apr 1, 2020
6c2a944
refactor: wip snapshot cleaner
osher-sade Apr 2, 2020
087d478
refactor: code review fixes
osher-sade Apr 2, 2020
b3d39fa
refactor: code review fixes
osher-sade Apr 2, 2020
f00c436
refactor: code review fixes
osher-sade Apr 2, 2020
6ea2ef3
refactor: code review fixes
osher-sade Apr 2, 2020
be3c729
Merge pull request #39 from Enigmatis/feature/offline-pagination
osher-sade Apr 2, 2020
7c7a88b
Merge remote-tracking branch 'origin/development' into snapshot-cleaner
osher-sade Apr 2, 2020
7bebeae
chore(release): 2.0.0-beta.10 [skip ci]
semantic-release-bot Apr 2, 2020
102635b
Merge branch 'development' into snapshot-cleaner
osher-sade Apr 2, 2020
1bf7143
feat(snapshot): added snapshot cleaner logic
osher-sade Apr 2, 2020
43a4e73
style: added snapshot cleaner logic
osher-sade Apr 2, 2020
2624c68
Update README.md
yarinvak Apr 2, 2020
5cbf979
Merge remote-tracking branch 'origin/development' into transactional-…
itaykl Apr 5, 2020
06fa4eb
refactor: fix conflicts and add the transactional mutations plugin
itaykl Apr 5, 2020
0825400
refactor: change in jest config
itaykl Apr 5, 2020
cdcd57c
test: try to fix the build failing tests
itaykl Apr 6, 2020
2f4b207
refactor: added logs for snapshot cleaner
osher-sade Apr 19, 2020
2dc26c6
refactor: added interval cleanup
osher-sade Apr 19, 2020
1809cf1
refactor: moved cleaner interval logic into snapshot-cleaner
osher-sade Apr 20, 2020
b6cb908
style: prettify
osher-sade Apr 20, 2020
0c377b8
Merge pull request #43 from Enigmatis/snapshot-cleaner
osher-sade Apr 20, 2020
0e64197
chore(release): 2.0.0-beta.11 [skip ci]
semantic-release-bot Apr 20, 2020
db3af54
fix: offline pagination works with auto
DoctorVoid Apr 20, 2020
30539f2
Update README.md
yarinvak Apr 20, 2020
29421f2
Update README.md
yarinvak Apr 20, 2020
06bcf04
Update README.md
yarinvak Apr 20, 2020
15ca126
fix: dependency to middlewares
chenshoo Apr 21, 2020
d8cda3c
fix: dependency to middlewares
chenshoo Apr 21, 2020
8c7dd02
fix: dependency to middlewares
chenshoo Apr 21, 2020
9bdb009
fix: dependency to middlewares
chenshoo Apr 21, 2020
aeecaaa
fix: upgrade polaris typeorm
chenshoo Apr 21, 2020
bcfd6de
fix: upgrade polaris typeorm
chenshoo Apr 21, 2020
ecf682e
Merge pull request #45 from Enigmatis/upgrade-typeorm
chenshoo Apr 21, 2020
43e39db
chore(release): 2.0.0-beta.12 [skip ci]
semantic-release-bot Apr 21, 2020
e414795
Merge branches 'development' and 'transactional-mutations' of https:/…
chenshoo Apr 21, 2020
6ae4d07
fix: upgrade polaris typeorm
chenshoo Apr 21, 2020
de9e605
fix: upgrade polaris typeorm
chenshoo Apr 21, 2020
79619e7
Merge branches 'beta-badge' and 'development' of https://github.com/E…
yarinvak Apr 21, 2020
25e986d
Merge pull request #46 from Enigmatis/beta-badge
yarinvak Apr 21, 2020
1e9a7b1
fix: static functions
chenshoo Apr 21, 2020
7857b80
test: add concurrent mutations tests.
itaykl Apr 22, 2020
44bf443
fix: finished fixing auto and implement tests
DoctorVoid Apr 22, 2020
2ea6ba2
fix: fixed tests
DoctorVoid Apr 23, 2020
7b324be
fix: review fixes
DoctorVoid Apr 23, 2020
3b7863a
Merge pull request #48 from Enigmatis/feature/automatic-snapshot
DoctorVoid Apr 23, 2020
cbfea5e
chore(release): 2.0.0-beta.13 [skip ci]
semantic-release-bot Apr 23, 2020
7a42a72
refactor: add plugin in polaris server creation.
itaykl Apr 26, 2020
ea029a7
Merge remote-tracking branch 'origin/development' into transactional-…
itaykl Apr 27, 2020
158bed6
test: fix the tests.
itaykl Apr 27, 2020
f5f256c
refactor: fix the express dependency.
itaykl Apr 27, 2020
170da65
refactor: little changes.
itaykl Apr 27, 2020
dff89c9
Merge remote-tracking branch 'origin/transactional-mutations' into re…
osher-sade Apr 27, 2020
62c1abc
fix: reality id in response headers is now fixed
osher-sade Apr 27, 2020
a5be87f
test: little changes.
itaykl Apr 27, 2020
ddd7dad
test: little changes.
itaykl Apr 27, 2020
ccd0843
Merge remote-tracking branch 'origin/development' into transactional-…
itaykl Apr 28, 2020
3783392
refactor: change init connection behavior.
itaykl Apr 28, 2020
812918b
test: add synchronize and drop schema.
itaykl Apr 28, 2020
0cc2a6a
Merge pull request #41 from Enigmatis/transactional-mutations
itaykl Apr 30, 2020
8d337fa
chore(release): 2.0.0-beta.14 [skip ci]
semantic-release-bot Apr 30, 2020
8f2f5c1
Merge remote-tracking branch 'origin/development' into reality-id-not…
osher-sade Apr 30, 2020
1bd9e60
Merge remote-tracking branch 'origin/development' into add-concurrent…
itaykl Apr 30, 2020
66bd2dc
refactor: changes in test server after merge from dev.
itaykl Apr 30, 2020
bb33e06
Merge pull request #49 from Enigmatis/reality-id-not-in-response-headers
osher-sade Apr 30, 2020
77e5b52
chore(release): 2.0.0-beta.15 [skip ci]
semantic-release-bot Apr 30, 2020
dd7cd48
test: changes after code reviews.
itaykl Apr 30, 2020
7bdacc5
Merge pull request #50 from Enigmatis/add-concurrent-mutations
itaykl Apr 30, 2020
059df84
ci: trying to enable codecov
osher-sade Apr 30, 2020
986436b
ci: configuring codecov
osher-sade Apr 30, 2020
d36097f
ci: configuring codecov
osher-sade Apr 30, 2020
861a406
ci: configuring codecov
osher-sade Apr 30, 2020
040f882
ci: configuring codecov
osher-sade Apr 30, 2020
6da7136
ci: configuring codecov
osher-sade Apr 30, 2020
3a92790
ci: configuring codecov
osher-sade Apr 30, 2020
2ae74b8
Merge pull request #51 from Enigmatis/codecov-support
osher-sade May 3, 2020
a272cb8
Merge branches 'development' and 'static-funcs' of https://github.com…
chenshoo May 3, 2020
5b0f67f
Merge pull request #52 from Enigmatis/static-funcs
chenshoo May 3, 2020
9537123
chore(release): 2.0.0-beta.16 [skip ci]
semantic-release-bot May 3, 2020
af59edd
fix: added prefetch
DoctorVoid May 3, 2020
05dec14
fix: upgrade polaris typeorm
chenshoo May 4, 2020
bb394d2
fix: snapshot plugin is no longer requiring injection of apollo server
osher-sade May 4, 2020
d0c9db5
style: prettify
osher-sade May 4, 2020
ae36fa1
fix: refactored the prefetch mechanism
DoctorVoid May 4, 2020
4ca57be
fix: added int tests
DoctorVoid May 4, 2020
41ce74f
fix: fixed if condition
osher-sade May 4, 2020
807e0a2
fix: review fixes
DoctorVoid May 5, 2020
0392b39
Merge pull request #53 from Enigmatis/feature/prefetch
DoctorVoid May 5, 2020
95cc248
chore(release): 2.0.0-beta.17 [skip ci]
semantic-release-bot May 5, 2020
8484333
Merge branch 'development' of https://github.com/Enigmatis/polaris-co…
chenshoo May 13, 2020
a082390
Merge branches 'development' and 'static-funcs' of https://github.com…
chenshoo May 13, 2020
3de8c0b
Merge pull request #54 from Enigmatis/separete-snapshot-plugin-from-o…
chenshoo May 13, 2020
813d039
chore(release): 2.0.0-beta.18 [skip ci]
semantic-release-bot May 13, 2020
cdfad35
fix: connection tests
chenshoo May 25, 2020
3a8ed2d
Merge pull request #56 from Enigmatis/fix-without-connection-tests
chenshoo May 26, 2020
4998850
chore(release): 2.0.0-beta.19 [skip ci]
semantic-release-bot May 26, 2020
987a4d6
fix: added a bit of transaction management
chenshoo Jun 1, 2020
f5d6588
fix: snapshot should not work if mutation
chenshoo Jun 8, 2020
8cb5e97
Merge branch 'development' of https://github.com/Enigmatis/polaris-co…
chenshoo Jun 8, 2020
b44bce6
Merge pull request #59 from Enigmatis/fix-snapshot-only-on-queries
chenshoo Jun 8, 2020
ab06be2
chore(release): 2.0.0-beta.20 [skip ci]
semantic-release-bot Jun 8, 2020
52e8b9d
fix: update apollo server
chenshoo Jun 11, 2020
9e55809
fix: update apollo server
chenshoo Jun 11, 2020
7de8077
Merge pull request #60 from Enigmatis/upgrade-apollo
chenshoo Jun 14, 2020
1fa9821
chore(release): 2.0.0-beta.21 [skip ci]
semantic-release-bot Jun 14, 2020
42c9cb8
Merge remote-tracking branch 'origin/development' into transactional-…
chenshoo Jul 5, 2020
fd132f4
style: lint fix
osher-sade Jul 5, 2020
a3287c2
style: lint fix
osher-sade Jul 5, 2020
51f6945
fix: snapshot process is now transactional
osher-sade Jul 5, 2020
e463c3b
fix: added await when dealing with a transaction
osher-sade Jul 7, 2020
53c89b0
fix: version is now defined when sending partial application props
osher-sade Jul 9, 2020
b3f717c
fix: playground assets load correctly
osher-sade Jul 9, 2020
bed4a6c
chore: updated dependencies
osher-sade Jul 9, 2020
c023f26
ci: added coverage folder to npmignore
osher-sade Jul 9, 2020
8d76d09
Merge pull request #62 from Enigmatis/version-url-fix
chenshoo Jul 9, 2020
09fea09
Merge remote-tracking branch 'origin/development' into offline-playgr…
osher-sade Jul 9, 2020
b1c9990
chore(release): 2.0.0-beta.22 [skip ci]
semantic-release-bot Jul 9, 2020
fa1bcbf
Merge pull request #63 from Enigmatis/offline-playground-fix
osher-sade Jul 9, 2020
9c08a49
chore(release): 2.0.0-beta.23 [skip ci]
semantic-release-bot Jul 9, 2020
c0da05f
Merge branch 'development' into transactional-offline-pagination
osher-sade Jul 9, 2020
d8cac37
fix: playground offline
Jul 12, 2020
a4d290d
Merge pull request #64 from Enigmatis/fix-offline-playground
chenshoo Jul 12, 2020
c6c37fb
fix: snapshot is now works as metadata
osher-sade Jul 12, 2020
6c2e37f
chore(release): 2.0.0-beta.24 [skip ci]
semantic-release-bot Jul 12, 2020
10c179c
fix: now works
osher-sade Jul 12, 2020
65a21e0
fix: should now work good
osher-sade Jul 12, 2020
0bca40c
Merge branch 'development' into transactional-offline-pagination
osher-sade Jul 13, 2020
dd918c5
refactor: added transaction flag in snapshot listener
osher-sade Jul 13, 2020
4e3992b
fix: add irrelevant-entities.test.ts test on dv not answering criteria
Jul 14, 2020
1a9043f
fix: pagination working with irrelevant entities
DoctorVoid Jul 14, 2020
98e3877
fix: fix playground
DoctorVoid Jul 14, 2020
fce0044
fix: fix test
DoctorVoid Jul 14, 2020
ed81127
fix: snapshot created before data
DoctorVoid Jul 15, 2020
bce31cb
fix: snapshot response is now correct
DoctorVoid Jul 15, 2020
4c0704b
fix: fixed tests
DoctorVoid Jul 16, 2020
1e14d4e
fix: updated
DoctorVoid Jul 19, 2020
eed759d
fix: fix wait for paging process
Jul 20, 2020
8aea9de
fix: fix wait for paging process
Jul 20, 2020
6b985c9
fix: fix wait for paging process
Jul 20, 2020
61dade6
fix: fix wait for paging process
Jul 20, 2020
33005d3
fix: fix wait for paging process
Jul 20, 2020
642a9c5
fix: fix wait for paging process
Jul 20, 2020
6f92341
fix: fix wait for paging process
Jul 20, 2020
b66acce
fix: fix wait for paging process
Jul 20, 2020
cf7bbdd
Merge remote-tracking branch 'origin/development' into snapshot-metadata
DoctorVoid Jul 21, 2020
319ca68
Merge pull request #65 from Enigmatis/upgrade-polaris-typeorm
chenshoo Jul 22, 2020
940b5d4
chore(release): 2.0.0-beta.25 [skip ci]
semantic-release-bot Jul 22, 2020
b5dcec2
fix: added tests
DoctorVoid Jul 22, 2020
7ab6e01
fix: updated
DoctorVoid Jul 26, 2020
ffd9349
fix: fixes
DoctorVoid Jul 26, 2020
2210653
fix: try travis without metadata snapshot tests
DoctorVoid Jul 26, 2020
f064197
fix: added test
DoctorVoid Jul 26, 2020
27a89cd
fix: added test
DoctorVoid Jul 26, 2020
a30a664
fix: updated tests
DoctorVoid Jul 26, 2020
e6e75ef
fix: fixed test timing
DoctorVoid Jul 28, 2020
7c3bb2f
Merge remote-tracking branch 'origin/development' into snapshot-metadata
DoctorVoid Jul 28, 2020
6f1297c
fix: review fixes
DoctorVoid Jul 28, 2020
165711a
fix: review fixes1
DoctorVoid Jul 28, 2020
ce9bd0a
fix: review fixes2
DoctorVoid Jul 28, 2020
55ea065
fix: review fixes3
DoctorVoid Jul 28, 2020
9521b96
Merge pull request #66 from Enigmatis/snapshot-metadata
chenshoo Jul 28, 2020
783da36
chore(release): 2.0.0-beta.26 [skip ci]
semantic-release-bot Jul 28, 2020
ccafe3e
Merge branch 'development' into transactional-offline-pagination
Aug 2, 2020
6b5f8dc
refactor: paging process is now transactional
osher-sade Aug 2, 2020
8d010ed
refactor: paging process is now transactional
osher-sade Aug 2, 2020
80a7a89
Merge pull request #61 from Enigmatis/transactional-offline-pagination
DoctorVoid Aug 2, 2020
b591eba
chore(release): 2.0.0-beta.27 [skip ci]
semantic-release-bot Aug 2, 2020
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
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/
src/
test/
docs/
coverage/
gulpfile.js
tsconfig.json
tslint.json
Expand Down
25 changes: 21 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
language: node_js

os: linux

node_js:
- 12

before_script:
- npm install -g codecov

script:
- npm run coverage

after_success:
- codecov

jobs:
include:
# Define the release stage that runs semantic-release
Expand All @@ -11,7 +22,13 @@ jobs:
# Advanced: optionally overwrite your default `script` step to skip the tests
# script: skip
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
- provider: script
skip_cleanup: true
script: npm run semantic-release
on:
branch: master
- provider: script
skip_cleanup: true
script: npm run semantic-release
on:
branch: development
323 changes: 323 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

197 changes: 189 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
![Polaris-logo](static/img/polariscoolsm.png)
<p align="center">
<img height="190" src="https://github.com/Enigmatis/polaris-nest-logger/raw/master/polarisen.png" alt="polaris logo" /><br><br>
Create a graphql service easily, integrated with typeorm, middlewares, standard logs, and more!<br><br>
<img alt="npm (scoped)" src="https://img.shields.io/npm/v/@enigmatis/polaris-core">
<img alt="npm (scoped with tag)" src="https://img.shields.io/npm/v/@enigmatis/polaris-core/beta">
<img alt="Travis (.org) branch" src="https://travis-ci.com/Enigmatis/polaris-core.svg?branch=master">
<a href="https://www.codacy.com/gh/Enigmatis/polaris-core?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Enigmatis/polaris-core&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/6a403edb43684b2382728837f58bbfbb"/></a>
</p>

# polaris-core

[![NPM version](https://img.shields.io/npm/v/@enigmatis/polaris-core.svg?style=flat-square)](https://www.npmjs.com/package/@enigmatis/polaris-core)
[![Build Status](https://travis-ci.com/Enigmatis/polaris-core.svg?branch=master)](https://travis-ci.com/Enigmatis/polaris-core)

Polaris is a set of libraries that help you create the perfect graphql service, integrated with type orm and the hottest API standards.
polaris-core organizes all of the libraries for you, and let you create your graphql service as easily as it can be.

Expand All @@ -23,7 +27,7 @@ polaris-core organizes all of the libraries for you, and let you create your gra
This is the server that you will use in order to create your own standardized GraphQL server.\
`PolarisServer` uses `ApolloServer` and starts the server with `Express`.

### PolarisServerConfig
### PolarisServerOptions

Through this interface you should set the following configurations which will be supplied to the `PolarisServer`:

Expand All @@ -34,13 +38,17 @@ Through this interface you should set the following configurations which will be
- **port** (_number_) - Specify a port the `PolarisServer` should start the server on.
- **applicationProperties** (_ApplicationProperties - optional_) - Properties that describe your repository.
If you don't provide those properties, the core will put 'v1' in the version.
- **allowSubscription** (boolean - optional) - Responsible for creating a websocket endpoint for graphql subscriptions.
- **customMiddlewares** (_any[] - optional_) - Custom middlewares that can be provided the `PolarisServer` with.
- **customContext** (_(context: any, connection?: Connection) => any - optional_) - You can provide the `PolarisServer` your own custom context.
If you do not set your custom context, the core will use a default context.
- **loggerConfiguration** (_LoggerConfiguration - optional_) - This is an interface that defines the logger in the `PolarisServer`.
If you do not provide this property, the core will use default values for the logger.
- **middlewareConfiguration** (_MiddlewareConfiguration - optional_) - This is an interface that defines what core middlewares should be activated/disabled.
- **connection** (_Connection - optional_) - This class represents your connection with the database. Used in the core middlewares.
- **allowSubscription** (_boolean - optional_) - _Default: false._ Responsible for creating a websocket endpoint for graphql subscriptions.
- **shouldAddWarningsToExtensions** (_boolean - optional_) - _Default: true._ Specifies whether to return the warnings in the response extensions or not.
- **allowMandatoryHeaders** (_boolean - optional_) - _Default: false._ When set to true, every request must have `reality-id` and `requesting-sys` headers.

### MiddlewareConfiguration

Expand All @@ -50,10 +58,184 @@ As mentioned above, this interface defines what core middlewares should be activ
- **allowSoftDeleteMiddleware** (_boolean_) - Determine if `SoftDeleteMiddleware` should be applied to the request.
- **allowRealityMiddleware** (_boolean_) - Determine if `RealityMiddleware` should be applied to the request.

### Example
### Custom context

First we will define the new context type, pay attention that we just added a new field in the root of the context,
and a new header in the request headers object.

```typescript
import { PolarisGraphQLContext, PolarisRequestHeaders } from '@enigmatis/polaris-core';

interface CustomRequestHeaders extends PolarisRequestHeaders {
customHeader?: string | string[];
}

export interface CustomContext extends PolarisGraphQLContext {
customField: number;
requestHeaders: CustomRequestHeaders;
}
```

Then we will pass the custom context like this:

```typescript
import { ExpressContext, PolarisServer } from '@enigmatis/polaris-core';

const typeDefs = `...`;
const resolvers = { ... };

const customContext = (context: ExpressContext): Partial<CustomContext> => {
const { req } = context;

return {
customField: 1000,
requestHeaders: {
customHeader: req.headers['custom-header'],
},
};
};

const server = new PolarisServer({
typeDefs,
resolvers,
port: 8082,
customContext,
});
```

### Subscriptions

Add the Subscription object to your schema

```
export const typeDefs = `
type Query {
...
}

type Mutation {
...
updateBook(id: String!, newTitle: String!): [Book]!
...
}

type Subscription {
bookUpdated: Book
}

type Book implements RepositoryEntity {
...
}
`;

```

now let's implement the subscription resolver logic

```
import { PubSub } from '@enigmatis/polaris-core';

```Typescript
const pubsub = new PubSub();
const BOOK_UPDATED = 'BOOK_UPDATED';

export const resolvers = {
Query: { ... },
Mutation: { ... },
Subscription: {
bookUpdated: {
subscribe: () => pubsub.asyncIterator([BOOK_UPDATED]),
},
},
};
```

and inside the updateBook resolver we will publish the book that got changed:

```
pubsub.publish(BOOK_UPDATED, { bookUpdated: myBook })
```

When you create the server you have to allow subscriptions, so the server could create the endpoint

```
const server = new PolarisServer({
typeDefs,
resolvers,
port: 8080,
allowSubscription: true,
});
```

Just pay attention that in case you are using custom context as well, the subscription context will be different,
you can handle it like so:

```
const customContext = (context: ExpressContext): Partial<CustomContext> => {
const { req, connection } = context;
const headers = req ? req.headers : connection?.context;

return {
customField: 1000,
requestHeaders: {
customHeader: headers['custom-header'],
},
};
};
```

### Warnings

In order to have the ability of warnings, which returned in the extensions of the response, you will need to supply them to
polaris. you can supply the warnings through the context. let's see an example:

```
allBooksWithWarnings: async (
parent: any,
args: any,
context: PolarisGraphQLContext,
): Promise<Book[]> => {
const connection = getPolarisConnectionManager().get();
context.returnedExtensions.warnings = ['warning 1', 'warning 2'];
return connection.getRepository(Book).find(context, { relations: ['author'] });
}
```

And let's see an example of response with the warnings:

```json
{
"data": {
"allBooks": [
{
"id": "53afd7e5-bf59-4408-acbc-1c5ebb5ff146",
"title": "Book1",
"author": {
"firstName": "Author1",
"lastName": "First"
}
},
{
"id": "4fab24e4-f584-4077-bb93-09cdfc88b202",
"title": "Book2",
"author": {
"firstName": "Author2",
"lastName": "Two"
}
}
]
},
"extensions": {
"globalDataVersion": 2,
"warnings": ["warning 1", "warning 2"]
}
}
```

You can see inside the `extensions` that we have the warnings we defined earlier.

### Example

```typescript
import { ApplicationProperties, PolarisServer } from '@enigmatis/polaris-core';

const typeDefs = `
Expand Down Expand Up @@ -96,7 +278,6 @@ const server = new PolarisServer({
applicationProperties,
});
server.start();

```

For any additional help and requests, feel free to contact us :smile:
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']};
module.exports = { extends: ['@commitlint/config-conventional'] };
11 changes: 4 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: [
"ts",
"js",
],
moduleFileExtensions: ['ts', 'js'],
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: [
"**/*.test.ts"
],
testMatch: ['**/*.test.ts'],
testTimeout: 150000,
coverageDirectory: './coverage/',
};
Loading