@platformatic/sql-graphql 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/{475e591b-b773-4ada-87d0-db538511c660.json → 02e6172c-f2ba-40f1-9d5d-86451759372c.json} +0 -0
- package/.nyc_output/06e1b082-c272-4876-b72f-14a940fb4e16.json +1 -0
- package/.nyc_output/393706b4-dd23-4644-a301-1ae1b551d5a0.json +1 -0
- package/.nyc_output/49ebb061-4831-4245-aeb8-dea830e8513b.json +1 -0
- package/.nyc_output/4c84319f-8089-4a76-8f49-474d69c477e2.json +1 -0
- package/.nyc_output/64081cdd-16a1-4dac-959c-6bd9f98b458e.json +1 -0
- package/.nyc_output/6a1062ee-935e-4b4d-9dd7-cc70277e5916.json +1 -0
- package/.nyc_output/7d3bbc3d-1c87-46e8-93d7-372bb91a5784.json +1 -0
- package/.nyc_output/9b470ca8-a83d-4499-9830-fa4698aa8655.json +1 -0
- package/.nyc_output/d470f916-c2cc-4ace-9341-9893e631826b.json +1 -0
- package/.nyc_output/df3d5175-9faa-48e8-b218-b3b5e9709f08.json +1 -0
- package/.nyc_output/ee904462-d684-4118-aa0a-58d306f34e5e.json +1 -0
- package/.nyc_output/ef850e84-b27d-4a2f-838c-56312a338f26.json +1 -0
- package/.nyc_output/f699a0f3-0d25-4890-a6de-94d8cdedb7d6.json +1 -0
- package/.nyc_output/f782edc5-072d-48f2-9c74-f0bcd7b86010.json +1 -0
- package/.nyc_output/f818f3a6-33e4-4b4c-805d-69e3274bf1d1.json +1 -0
- package/.nyc_output/processinfo/02e6172c-f2ba-40f1-9d5d-86451759372c.json +1 -0
- package/.nyc_output/processinfo/06e1b082-c272-4876-b72f-14a940fb4e16.json +1 -0
- package/.nyc_output/processinfo/393706b4-dd23-4644-a301-1ae1b551d5a0.json +1 -0
- package/.nyc_output/processinfo/49ebb061-4831-4245-aeb8-dea830e8513b.json +1 -0
- package/.nyc_output/processinfo/4c84319f-8089-4a76-8f49-474d69c477e2.json +1 -0
- package/.nyc_output/processinfo/64081cdd-16a1-4dac-959c-6bd9f98b458e.json +1 -0
- package/.nyc_output/processinfo/6a1062ee-935e-4b4d-9dd7-cc70277e5916.json +1 -0
- package/.nyc_output/processinfo/7d3bbc3d-1c87-46e8-93d7-372bb91a5784.json +1 -0
- package/.nyc_output/processinfo/9b470ca8-a83d-4499-9830-fa4698aa8655.json +1 -0
- package/.nyc_output/processinfo/d470f916-c2cc-4ace-9341-9893e631826b.json +1 -0
- package/.nyc_output/processinfo/df3d5175-9faa-48e8-b218-b3b5e9709f08.json +1 -0
- package/.nyc_output/processinfo/ee904462-d684-4118-aa0a-58d306f34e5e.json +1 -0
- package/.nyc_output/processinfo/ef850e84-b27d-4a2f-838c-56312a338f26.json +1 -0
- package/.nyc_output/processinfo/f699a0f3-0d25-4890-a6de-94d8cdedb7d6.json +1 -0
- package/.nyc_output/processinfo/f782edc5-072d-48f2-9c74-f0bcd7b86010.json +1 -0
- package/.nyc_output/processinfo/f818f3a6-33e4-4b4c-805d-69e3274bf1d1.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/index.js +19 -2
- package/lib/entity-to-type.js +1 -0
- package/lib/relationship.js +32 -3
- package/lib/subscriptions.js +89 -0
- package/package.json +6 -4
- package/test/helper.js +18 -0
- package/test/relations.test.js +332 -6
- package/test/subscription.test.js +336 -0
- package/.nyc_output/28567d89-45dc-4aa4-8d9d-4c8b713612e5.json +0 -1
- package/.nyc_output/4956602f-f6bd-4aef-bc4c-3d019bf6d754.json +0 -1
- package/.nyc_output/4c93feaa-384f-4a7c-b7bf-070cecebf72c.json +0 -1
- package/.nyc_output/6e295e9b-655e-43fd-a92a-75d058bed16d.json +0 -1
- package/.nyc_output/79fec06e-8965-498f-a023-624db14cdca7.json +0 -1
- package/.nyc_output/7f365fa0-3cdb-4303-ad17-59e3639745cc.json +0 -1
- package/.nyc_output/92f8aaa6-0c3d-4833-8544-93e0be94a868.json +0 -1
- package/.nyc_output/a4edd7d2-26a6-46ca-a79e-bc52a9308d76.json +0 -1
- package/.nyc_output/b152f368-1d63-4d9d-bd3a-97bb6b761ca8.json +0 -1
- package/.nyc_output/cc4af553-54c0-4a1e-9980-b7d8534e9010.json +0 -1
- package/.nyc_output/e0eb89e2-5c3c-4b39-8237-5827918c9774.json +0 -1
- package/.nyc_output/e640b1f5-34e9-4ac5-8691-3fc4b925739b.json +0 -1
- package/.nyc_output/f3e7d9f6-b598-48c5-9ebe-18071958a7d8.json +0 -1
- package/.nyc_output/fb0cb3f2-69da-49fa-bd3c-f13eceee0d3d.json +0 -1
- package/.nyc_output/processinfo/28567d89-45dc-4aa4-8d9d-4c8b713612e5.json +0 -1
- package/.nyc_output/processinfo/475e591b-b773-4ada-87d0-db538511c660.json +0 -1
- package/.nyc_output/processinfo/4956602f-f6bd-4aef-bc4c-3d019bf6d754.json +0 -1
- package/.nyc_output/processinfo/4c93feaa-384f-4a7c-b7bf-070cecebf72c.json +0 -1
- package/.nyc_output/processinfo/6e295e9b-655e-43fd-a92a-75d058bed16d.json +0 -1
- package/.nyc_output/processinfo/79fec06e-8965-498f-a023-624db14cdca7.json +0 -1
- package/.nyc_output/processinfo/7f365fa0-3cdb-4303-ad17-59e3639745cc.json +0 -1
- package/.nyc_output/processinfo/92f8aaa6-0c3d-4833-8544-93e0be94a868.json +0 -1
- package/.nyc_output/processinfo/a4edd7d2-26a6-46ca-a79e-bc52a9308d76.json +0 -1
- package/.nyc_output/processinfo/b152f368-1d63-4d9d-bd3a-97bb6b761ca8.json +0 -1
- package/.nyc_output/processinfo/cc4af553-54c0-4a1e-9980-b7d8534e9010.json +0 -1
- package/.nyc_output/processinfo/e0eb89e2-5c3c-4b39-8237-5827918c9774.json +0 -1
- package/.nyc_output/processinfo/e640b1f5-34e9-4ac5-8691-3fc4b925739b.json +0 -1
- package/.nyc_output/processinfo/f3e7d9f6-b598-48c5-9ebe-18071958a7d8.json +0 -1
- package/.nyc_output/processinfo/fb0cb3f2-69da-49fa-bd3c-f13eceee0d3d.json +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85677,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/insert.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554723203,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/d470f916-c2cc-4ace-9341-9893e631826b.json","externalId":"test/insert.test.js","uuid":"d470f916-c2cc-4ace-9341-9893e631826b","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85684,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/sqlite.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554727179,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/df3d5175-9faa-48e8-b218-b3b5e9709f08.json","externalId":"test/sqlite.test.js","uuid":"df3d5175-9faa-48e8-b218-b3b5e9709f08","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85681,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/order_by.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554725833,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/ee904462-d684-4118-aa0a-58d306f34e5e.json","externalId":"test/order_by.test.js","uuid":"ee904462-d684-4118-aa0a-58d306f34e5e","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85685,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/subscription.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554727584,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/ef850e84-b27d-4a2f-838c-56312a338f26.json","externalId":"test/subscription.test.js","uuid":"ef850e84-b27d-4a2f-838c-56312a338f26","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85672,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/count.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554721187,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/f699a0f3-0d25-4890-a6de-94d8cdedb7d6.json","externalId":"test/count.test.js","uuid":"f699a0f3-0d25-4890-a6de-94d8cdedb7d6","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85679,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/nested.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554725030,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/f782edc5-072d-48f2-9c74-f0bcd7b86010.json","externalId":"test/nested.test.js","uuid":"f782edc5-072d-48f2-9c74-f0bcd7b86010","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","pid":85676,"argv":["/Users/matteo/.nvm/versions/node/v18.12.0/bin/node","/Users/matteo/Repositories/platformatic/packages/sql-graphql/test/ignore.test.js"],"execArgv":[],"cwd":"/Users/matteo/Repositories/platformatic/packages/sql-graphql","time":1667554722826,"ppid":85671,"coverageFilename":"/Users/matteo/Repositories/platformatic/packages/sql-graphql/.nyc_output/f818f3a6-33e4-4b4c-805d-69e3274bf1d1.json","externalId":"test/ignore.test.js","uuid":"f818f3a6-33e4-4b4c-805d-69e3274bf1d1","files":["/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js","/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"processes":{"
|
|
1
|
+
{"processes":{"02e6172c-f2ba-40f1-9d5d-86451759372c":{"parent":null,"children":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"]},"06e1b082-c272-4876-b72f-14a940fb4e16":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/hooks.test.js","children":[]},"393706b4-dd23-4644-a301-1ae1b551d5a0":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/where.test.js","children":[]},"49ebb061-4831-4245-aeb8-dea830e8513b":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/no-modification-of-entity.test.js","children":[]},"4c84319f-8089-4a76-8f49-474d69c477e2":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/relations.test.js","children":[]},"64081cdd-16a1-4dac-959c-6bd9f98b458e":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/datatypes.test.js","children":[]},"6a1062ee-935e-4b4d-9dd7-cc70277e5916":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/inserted_updated_at.test.js","children":[]},"7d3bbc3d-1c87-46e8-93d7-372bb91a5784":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/simple.test.js","children":[]},"9b470ca8-a83d-4499-9830-fa4698aa8655":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/federation.test.js","children":[]},"d470f916-c2cc-4ace-9341-9893e631826b":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/insert.test.js","children":[]},"df3d5175-9faa-48e8-b218-b3b5e9709f08":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/sqlite.test.js","children":[]},"ee904462-d684-4118-aa0a-58d306f34e5e":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/order_by.test.js","children":[]},"ef850e84-b27d-4a2f-838c-56312a338f26":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/subscription.test.js","children":[]},"f699a0f3-0d25-4890-a6de-94d8cdedb7d6":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/count.test.js","children":[]},"f782edc5-072d-48f2-9c74-f0bcd7b86010":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/nested.test.js","children":[]},"f818f3a6-33e4-4b4c-805d-69e3274bf1d1":{"parent":"02e6172c-f2ba-40f1-9d5d-86451759372c","externalId":"test/ignore.test.js","children":[]}},"files":{"/Users/matteo/Repositories/platformatic/packages/sql-graphql/index.js":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"],"/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/entity-to-type.js":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"],"/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/utils.js":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"],"/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/relationship.js":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"],"/Users/matteo/Repositories/platformatic/packages/sql-graphql/lib/subscriptions.js":["06e1b082-c272-4876-b72f-14a940fb4e16","393706b4-dd23-4644-a301-1ae1b551d5a0","49ebb061-4831-4245-aeb8-dea830e8513b","4c84319f-8089-4a76-8f49-474d69c477e2","64081cdd-16a1-4dac-959c-6bd9f98b458e","6a1062ee-935e-4b4d-9dd7-cc70277e5916","7d3bbc3d-1c87-46e8-93d7-372bb91a5784","9b470ca8-a83d-4499-9830-fa4698aa8655","d470f916-c2cc-4ace-9341-9893e631826b","df3d5175-9faa-48e8-b218-b3b5e9709f08","ee904462-d684-4118-aa0a-58d306f34e5e","ef850e84-b27d-4a2f-838c-56312a338f26","f699a0f3-0d25-4890-a6de-94d8cdedb7d6","f782edc5-072d-48f2-9c74-f0bcd7b86010","f818f3a6-33e4-4b4c-805d-69e3274bf1d1"]},"externalIds":{"test/hooks.test.js":{"root":"06e1b082-c272-4876-b72f-14a940fb4e16","children":[]},"test/where.test.js":{"root":"393706b4-dd23-4644-a301-1ae1b551d5a0","children":[]},"test/no-modification-of-entity.test.js":{"root":"49ebb061-4831-4245-aeb8-dea830e8513b","children":[]},"test/relations.test.js":{"root":"4c84319f-8089-4a76-8f49-474d69c477e2","children":[]},"test/datatypes.test.js":{"root":"64081cdd-16a1-4dac-959c-6bd9f98b458e","children":[]},"test/inserted_updated_at.test.js":{"root":"6a1062ee-935e-4b4d-9dd7-cc70277e5916","children":[]},"test/simple.test.js":{"root":"7d3bbc3d-1c87-46e8-93d7-372bb91a5784","children":[]},"test/federation.test.js":{"root":"9b470ca8-a83d-4499-9830-fa4698aa8655","children":[]},"test/insert.test.js":{"root":"d470f916-c2cc-4ace-9341-9893e631826b","children":[]},"test/sqlite.test.js":{"root":"df3d5175-9faa-48e8-b218-b3b5e9709f08","children":[]},"test/order_by.test.js":{"root":"ee904462-d684-4118-aa0a-58d306f34e5e","children":[]},"test/subscription.test.js":{"root":"ef850e84-b27d-4a2f-838c-56312a338f26","children":[]},"test/count.test.js":{"root":"f699a0f3-0d25-4890-a6de-94d8cdedb7d6","children":[]},"test/nested.test.js":{"root":"f782edc5-072d-48f2-9c74-f0bcd7b86010","children":[]},"test/ignore.test.js":{"root":"f818f3a6-33e4-4b4c-805d-69e3274bf1d1","children":[]}}}
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const constructGraph = require('./lib/entity-to-type')
|
|
|
5
5
|
const mercurius = require('mercurius')
|
|
6
6
|
const graphql = require('graphql')
|
|
7
7
|
const establishRelations = require('./lib/relationship')
|
|
8
|
+
const setupSubscriptions = require('./lib/subscriptions')
|
|
8
9
|
const scalars = require('graphql-scalars')
|
|
9
10
|
|
|
10
11
|
async function mapperToGraphql (app, opts) {
|
|
@@ -24,6 +25,8 @@ async function mapperToGraphql (app, opts) {
|
|
|
24
25
|
federationReplacements,
|
|
25
26
|
federationMetadata: opts.federationMetadata
|
|
26
27
|
}
|
|
28
|
+
const metaMap = new Map()
|
|
29
|
+
|
|
27
30
|
if (Object.keys(mapper.entities).length === 0) {
|
|
28
31
|
// no schema
|
|
29
32
|
queryTopFields.hello = { type: graphql.GraphQLString }
|
|
@@ -31,7 +34,6 @@ async function mapperToGraphql (app, opts) {
|
|
|
31
34
|
hello: () => 'Hello Platformatic!'
|
|
32
35
|
}
|
|
33
36
|
} else {
|
|
34
|
-
const metaMap = new Map()
|
|
35
37
|
for (const entity of Object.values(mapper.entities)) {
|
|
36
38
|
relations.push(...entity.relations)
|
|
37
39
|
const meta = constructGraph(app, entity, graphOpts)
|
|
@@ -85,7 +87,21 @@ async function mapperToGraphql (app, opts) {
|
|
|
85
87
|
delete resolvers.Mutation
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
let
|
|
90
|
+
let subscription
|
|
91
|
+
if (app.platformatic.mq) {
|
|
92
|
+
const entitiesList = Object.keys(app.platformatic.entities)
|
|
93
|
+
const ignoreList = opts.subscriptionIgnore || []
|
|
94
|
+
|
|
95
|
+
if (entitiesList.length - ignoreList.length > 0) {
|
|
96
|
+
opts.subscription = {
|
|
97
|
+
emitter: app.platformatic.mq
|
|
98
|
+
}
|
|
99
|
+
// TODO support ignoring some of those
|
|
100
|
+
subscription = setupSubscriptions(app, metaMap, resolvers, ignoreList)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let sdl = graphql.printSchema(new graphql.GraphQLSchema({ query, mutation, subscription }))
|
|
89
105
|
|
|
90
106
|
if (opts.federationMetadata) {
|
|
91
107
|
for (const replacement of federationReplacements) {
|
|
@@ -108,6 +124,7 @@ async function mapperToGraphql (app, opts) {
|
|
|
108
124
|
}
|
|
109
125
|
|
|
110
126
|
opts.graphiql = opts.graphiql !== false
|
|
127
|
+
|
|
111
128
|
await app.register(mercurius, {
|
|
112
129
|
...opts,
|
|
113
130
|
schema: sdl,
|
package/lib/entity-to-type.js
CHANGED
package/lib/relationship.js
CHANGED
|
@@ -16,6 +16,7 @@ module.exports = function establishRelations (app, relations, resolvers, loaders
|
|
|
16
16
|
for (const relation of relations) {
|
|
17
17
|
assert(relation.table_name, 'table_name is required')
|
|
18
18
|
assert(relation.foreign_table_name, 'foreign_table_name is required')
|
|
19
|
+
assert(relation.column_name.toLowerCase().endsWith('id'), 'The column with id reference must be ended with `id` postfix')
|
|
19
20
|
|
|
20
21
|
const current = tablesTypeMap[relation.table_name]
|
|
21
22
|
const foreign = tablesTypeMap[relation.foreign_table_name]
|
|
@@ -23,12 +24,12 @@ module.exports = function establishRelations (app, relations, resolvers, loaders
|
|
|
23
24
|
|
|
24
25
|
// current to foreign
|
|
25
26
|
{
|
|
26
|
-
const lowered = lowerCaseFirst(
|
|
27
|
+
const lowered = lowerCaseFirst(camelcase(cutOutIdEnding(relation.column_name)))
|
|
27
28
|
if (!relationships[current.type] || relationships[current.type][lowered] !== false) {
|
|
28
29
|
current.fields[lowered] = { type: foreign.type }
|
|
29
30
|
const originalField = camelcase(relation.column_name)
|
|
30
31
|
delete current.fields[originalField]
|
|
31
|
-
loaders[current.type] = resolvers[current.type] || {}
|
|
32
|
+
loaders[current.type] = loaders[current.type] || resolvers[current.type] || {}
|
|
32
33
|
loaders[current.type][lowered] = {
|
|
33
34
|
loader (queries, ctx) {
|
|
34
35
|
const keys = queries.map(({ obj }) => {
|
|
@@ -49,13 +50,23 @@ module.exports = function establishRelations (app, relations, resolvers, loaders
|
|
|
49
50
|
if (!relationships[foreign.type] || relationships[foreign.type][lowered] !== false) {
|
|
50
51
|
foreign.fields[lowered] = queryTopFields[lowered]
|
|
51
52
|
resolvers[foreign.type] = resolvers[foreign.type] || {}
|
|
52
|
-
|
|
53
|
+
const resolveRelation = async function (obj, args, ctx, info) {
|
|
53
54
|
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet, new Set())
|
|
54
55
|
const toSearch = { ...args, fields: [...fields, relation.column_name], ctx }
|
|
55
56
|
toSearch.where = toSearch.where || {}
|
|
56
57
|
toSearch.where[camelcase(relation.column_name)] = { eq: obj.id }
|
|
57
58
|
return current.entity.find(toSearch)
|
|
58
59
|
}
|
|
60
|
+
if (resolvers[foreign.type][lowered] === undefined) {
|
|
61
|
+
resolvers[foreign.type][lowered] = resolveRelation
|
|
62
|
+
} else {
|
|
63
|
+
const previousResolve = resolvers[foreign.type][lowered]
|
|
64
|
+
resolvers[foreign.type][lowered] = async function (obj, args, ctx, info) {
|
|
65
|
+
const previousResponse = await previousResolve(obj, args, ctx, info)
|
|
66
|
+
const currentResponse = await resolveRelation(obj, args, ctx, info)
|
|
67
|
+
return uniqueBy([...previousResponse, ...currentResponse], findPrimaryColumnName(current.entity.camelCasedFields))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
72
|
}
|
|
@@ -65,3 +76,21 @@ function lowerCaseFirst (str) {
|
|
|
65
76
|
str = str.toString()
|
|
66
77
|
return str.charAt(0).toLowerCase() + str.slice(1)
|
|
67
78
|
}
|
|
79
|
+
|
|
80
|
+
function cutOutIdEnding (str) {
|
|
81
|
+
str = str.toString()
|
|
82
|
+
return str.slice(0, str.toLowerCase().lastIndexOf('id'))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function findPrimaryColumnName (camelCasedFields) {
|
|
86
|
+
return Object.entries(camelCasedFields).find(([, options]) => options.primaryKey)[0]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function unique (arr) {
|
|
90
|
+
return [...new Set(arr)]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function uniqueBy (arr, key) {
|
|
94
|
+
const uniqueValues = unique(arr.map(el => el[key]))
|
|
95
|
+
return uniqueValues.map(value => arr.find(el => el[key] === value))
|
|
96
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const graphql = require('graphql')
|
|
4
|
+
|
|
5
|
+
function setupSubscriptions (app, metaMap, resolvers, ignores) {
|
|
6
|
+
const fields = {}
|
|
7
|
+
resolvers.Subscription = {}
|
|
8
|
+
for (const [field, meta] of metaMap) {
|
|
9
|
+
if (ignores.indexOf(field.singularName) >= 0) {
|
|
10
|
+
continue
|
|
11
|
+
}
|
|
12
|
+
const { type } = meta
|
|
13
|
+
const saved = `${field.singularName}Saved`
|
|
14
|
+
fields[saved] = {
|
|
15
|
+
type
|
|
16
|
+
}
|
|
17
|
+
resolvers.Subscription[saved] = {
|
|
18
|
+
subscribe: async function * (_, query, ctx, info) {
|
|
19
|
+
const log = ctx.reply.request.log
|
|
20
|
+
const { pubsub } = ctx
|
|
21
|
+
const entity = app.platformatic.entities[field.singularName]
|
|
22
|
+
const topic = await entity.getSubscriptionTopic({ action: 'save', ctx })
|
|
23
|
+
log.trace({ topic }, 'subscribed')
|
|
24
|
+
const res = await pubsub.subscribe(topic)
|
|
25
|
+
const primaryKey = entity.primaryKey
|
|
26
|
+
const fields = meta.getFields([{ info }])
|
|
27
|
+
|
|
28
|
+
for await (const msg of res) {
|
|
29
|
+
// TODO optimize this by not calling find() if the subscriber is only asking for the id.
|
|
30
|
+
try {
|
|
31
|
+
log.trace({ msg, entity: field.singularName }, 'graphql subscription augmenting data')
|
|
32
|
+
// The alternative to augmenting the data is installing a resolver for every type
|
|
33
|
+
// of a given entity that loads up the type via a dataloader.
|
|
34
|
+
const found = await entity.find({ where: { [primaryKey]: { eq: msg[primaryKey] } }, fields, ctx })
|
|
35
|
+
// The following could happen in case of a race condition
|
|
36
|
+
// testing it would be very hard, so we skip it for now
|
|
37
|
+
/* istanbul ignore next */
|
|
38
|
+
if (found.length === 0) {
|
|
39
|
+
log.warn({ ...msg.payload, entity: field.singularName }, 'graphql subscription could not find element')
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
const toYield = { [saved]: found[0] }
|
|
43
|
+
log.trace({ yield: toYield, entity: field.singularName }, 'graphql subscription augmented data')
|
|
44
|
+
yield toYield
|
|
45
|
+
} catch (err) {
|
|
46
|
+
/* istanbul ignore next */
|
|
47
|
+
log.warn({ err, entity: field.singularName }, 'graphql subscription error')
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const deleted = `${field.singularName}Deleted`
|
|
54
|
+
fields[deleted] = {
|
|
55
|
+
type: new graphql.GraphQLObjectType({
|
|
56
|
+
name: `${field.name}Deleted`,
|
|
57
|
+
fields: {
|
|
58
|
+
[field.primaryKey]: {
|
|
59
|
+
type: meta.fields[field.primaryKey].type
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
resolvers.Subscription[deleted] = {
|
|
65
|
+
subscribe: async (_, query, ctx, info) => {
|
|
66
|
+
const { pubsub } = ctx
|
|
67
|
+
const entity = app.platformatic.entities[field.singularName]
|
|
68
|
+
const topic = await entity.getSubscriptionTopic({ action: 'delete', ctx })
|
|
69
|
+
const res = await pubsub.subscribe(topic)
|
|
70
|
+
ctx.reply.request.log.trace({ topic }, 'subscribed')
|
|
71
|
+
return wrap(res, deleted)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const subscription = new graphql.GraphQLObjectType({
|
|
76
|
+
name: 'Subscription',
|
|
77
|
+
fields
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return subscription
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function * wrap (iterator, key) {
|
|
84
|
+
for await (const msg of iterator) {
|
|
85
|
+
yield { [key]: msg }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = setupSubscriptions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Map SQL dbs to GraphQL",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/plaformatic/platformatic#readme",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@platformatic/sql-
|
|
17
|
+
"@platformatic/sql-events": "0.5.0",
|
|
18
|
+
"@platformatic/sql-mapper": "0.5.0",
|
|
18
19
|
"fastify": "^4.6.0",
|
|
19
20
|
"snazzy": "^9.0.0",
|
|
20
21
|
"standard": "^17.0.0",
|
|
21
22
|
"tap": "^16.0.0",
|
|
22
|
-
"tsd": "^0.24.0"
|
|
23
|
+
"tsd": "^0.24.0",
|
|
24
|
+
"ws": "^8.9.0"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"camelcase": "^6.0.0",
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"graphql-scalars": "^1.13.1",
|
|
29
31
|
"graphql-type-json": "^0.3.2",
|
|
30
32
|
"inflected": "^2.1.0",
|
|
31
|
-
"mercurius": "^11.
|
|
33
|
+
"mercurius": "^11.2.0"
|
|
32
34
|
},
|
|
33
35
|
"tsd": {
|
|
34
36
|
"directory": "test/types"
|
package/test/helper.js
CHANGED
|
@@ -68,4 +68,22 @@ module.exports.clear = async function (db, sql) {
|
|
|
68
68
|
await db.query(sql`DROP TABLE graphs`)
|
|
69
69
|
} catch {
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await db.query(sql`DROP TABLE books`)
|
|
74
|
+
} catch (err) {
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
await db.query(sql`DROP TABLE authors`)
|
|
78
|
+
} catch (err) {
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await db.query(sql`DROP TABLE organizations`)
|
|
83
|
+
} catch (err) {
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
await db.query(sql`DROP TABLE individuals`)
|
|
87
|
+
} catch (err) {
|
|
88
|
+
}
|
|
71
89
|
}
|