From ae49fea003d66e82d0b202767f8fe5cb8834e59a Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Tue, 12 Nov 2024 09:59:57 -0800 Subject: [PATCH] feat(big-int): adding in big int support --- pnpm-lock.yaml | 39 +++++++++++++------------ servers/list-api/package.json | 1 + servers/list-api/schema.graphql | 27 +++++++++-------- servers/list-api/src/resolvers/index.ts | 2 ++ 4 files changed, 39 insertions(+), 30 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dca48a68e..edf40b847 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,7 +36,7 @@ importers: devDependencies: '@commitlint/cli': specifier: 19.5.0 - version: 19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241108) + version: 19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241112) '@commitlint/config-conventional': specifier: ^19.5.0 version: 19.5.0 @@ -45,7 +45,7 @@ importers: version: link:packages/eslint-config syncpack: specifier: ^13.0.0 - version: 13.0.0(typescript@5.8.0-dev.20241108) + version: 13.0.0(typescript@5.8.0-dev.20241112) tsconfig: specifier: workspace:* version: link:packages/tsconfig @@ -3286,6 +3286,9 @@ importers: graphql-depth-limit: specifier: 1.1.0 version: 1.1.0(graphql@16.9.0) + graphql-scalars: + specifier: ^1.23.0 + version: 1.23.0(graphql@16.9.0) graphql-tag: specifier: 2.12.6 version: 2.12.6(graphql@16.9.0) @@ -13941,8 +13944,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - typescript@5.8.0-dev.20241108: - resolution: {integrity: sha512-4QncqXkNRtmod3q92DswLBXVX8Cc+FV2BEH4KZnP8bzqPTjUAZBq/qXl0u7pXEhH+hZOxeDqI3vvn8ry8lMt3Q==} + typescript@5.8.0-dev.20241112: + resolution: {integrity: sha512-h5Ik9z9sIGe898ya+9bG+XBZQHzSYFY0Q1X9QmsDjcX2xf3jwNnWaUAE0NLVw0Lx+XBRBB2qf7GyfeqDNrzofQ==} engines: {node: '>=14.17'} hasBin: true @@ -16584,11 +16587,11 @@ snapshots: dependencies: commander: 12.1.0 - '@commitlint/cli@19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241108)': + '@commitlint/cli@19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241112)': dependencies: '@commitlint/format': 19.5.0 '@commitlint/lint': 19.5.0 - '@commitlint/load': 19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241108) + '@commitlint/load': 19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241112) '@commitlint/read': 19.5.0 '@commitlint/types': 19.5.0 tinyexec: 0.3.1 @@ -16635,15 +16638,15 @@ snapshots: '@commitlint/rules': 19.5.0 '@commitlint/types': 19.5.0 - '@commitlint/load@19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241108)': + '@commitlint/load@19.5.0(@types/node@22.9.0)(typescript@5.8.0-dev.20241112)': dependencies: '@commitlint/config-validator': 19.5.0 '@commitlint/execute-rule': 19.5.0 '@commitlint/resolve-extends': 19.5.0 '@commitlint/types': 19.5.0 chalk: 5.3.0 - cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241108) - cosmiconfig-typescript-loader: 5.1.0(@types/node@22.9.0)(cosmiconfig@9.0.0(typescript@5.8.0-dev.20241108))(typescript@5.8.0-dev.20241108) + cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241112) + cosmiconfig-typescript-loader: 5.1.0(@types/node@22.9.0)(cosmiconfig@9.0.0(typescript@5.8.0-dev.20241112))(typescript@5.8.0-dev.20241112) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -21675,12 +21678,12 @@ snapshots: object-assign: 4.1.1 vary: 1.1.2 - cosmiconfig-typescript-loader@5.1.0(@types/node@22.9.0)(cosmiconfig@9.0.0(typescript@5.8.0-dev.20241108))(typescript@5.8.0-dev.20241108): + cosmiconfig-typescript-loader@5.1.0(@types/node@22.9.0)(cosmiconfig@9.0.0(typescript@5.8.0-dev.20241112))(typescript@5.8.0-dev.20241112): dependencies: '@types/node': 22.9.0 - cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241108) + cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241112) jiti: 1.21.6 - typescript: 5.8.0-dev.20241108 + typescript: 5.8.0-dev.20241112 cosmiconfig@8.3.6(typescript@5.6.3): dependencies: @@ -21700,14 +21703,14 @@ snapshots: optionalDependencies: typescript: 5.6.3 - cosmiconfig@9.0.0(typescript@5.8.0-dev.20241108): + cosmiconfig@9.0.0(typescript@5.8.0-dev.20241112): dependencies: env-paths: 2.2.1 import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 optionalDependencies: - typescript: 5.8.0-dev.20241108 + typescript: 5.8.0-dev.20241112 cpu-features@0.0.2: dependencies: @@ -22029,7 +22032,7 @@ snapshots: dependencies: semver: 7.6.3 shelljs: 0.8.5 - typescript: 5.8.0-dev.20241108 + typescript: 5.8.0-dev.20241112 dreamopt@0.8.0: dependencies: @@ -26772,13 +26775,13 @@ snapshots: '@pkgr/core': 0.1.1 tslib: 2.8.0 - syncpack@13.0.0(typescript@5.8.0-dev.20241108): + syncpack@13.0.0(typescript@5.8.0-dev.20241112): dependencies: '@effect/schema': 0.71.1(effect@3.6.5) chalk: 5.3.0 chalk-template: 1.1.0 commander: 12.1.0 - cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241108) + cosmiconfig: 9.0.0(typescript@5.8.0-dev.20241112) effect: 3.6.5 enquirer: 2.4.1 fast-check: 3.21.0 @@ -27177,7 +27180,7 @@ snapshots: typescript@5.6.3: {} - typescript@5.8.0-dev.20241108: {} + typescript@5.8.0-dev.20241112: {} ua-parser-js@1.0.39: {} diff --git a/servers/list-api/package.json b/servers/list-api/package.json index 51d32bad5..4b13a7320 100644 --- a/servers/list-api/package.json +++ b/servers/list-api/package.json @@ -44,6 +44,7 @@ "graphql": "16.9.0", "graphql-constraint-directive": "5.4.2", "graphql-depth-limit": "1.1.0", + "graphql-scalars": "^1.23.0", "graphql-tag": "2.12.6", "knex": "3.1.0", "locutus": "2.0.32", diff --git a/servers/list-api/schema.graphql b/servers/list-api/schema.graphql index 068624235..adef6350f 100644 --- a/servers/list-api/schema.graphql +++ b/servers/list-api/schema.graphql @@ -18,6 +18,9 @@ scalar ISOString scalar Url +scalar BigInt + + type SyncConflict implements BaseError { path: String! message: String! @@ -53,11 +56,11 @@ interface RemoteEntity { """ Unix timestamp of when the entity was created """ - _createdAt: Int + _createdAt: BigInt """ Unix timestamp of when the entity was last updated, if any property on the entity is modified this timestamp is set to the modified time """ - _updatedAt: Int + _updatedAt: BigInt """ Version of the entity, this will increment with each modification of the entity's field """ @@ -65,7 +68,7 @@ interface RemoteEntity { """ Unix timestamp of when the entity was deleted, 30 days after this date this entity will be HARD deleted from the database and no longer exist """ - _deletedAt: Int + _deletedAt: BigInt } """ @@ -182,7 +185,7 @@ type SavedItem implements RemoteEntity """ Timestamp that the SavedItem became favorited, null if not favorited """ - favoritedAt: Int + favoritedAt: BigInt """ Helper property to indicate if the SavedItem is archived """ @@ -190,7 +193,7 @@ type SavedItem implements RemoteEntity """ Timestamp that the SavedItem became archied, null if not archived """ - archivedAt: Int + archivedAt: BigInt """ Link to the underlying Pocket Item for the URL """ @@ -214,11 +217,11 @@ type SavedItem implements RemoteEntity """ Unix timestamp of when the entity was created """ - _createdAt: Int! + _createdAt: BigInt! """ Unix timestamp of when the entity was last updated, if any property on the entity is modified this timestamp is set to the modified time """ - _updatedAt: Int + _updatedAt: BigInt """ Version of the entity, this will increment with each modification of the entity's field """ @@ -226,7 +229,7 @@ type SavedItem implements RemoteEntity """ Unix timestamp of when the entity was deleted, 30 days after this date this entity will be HARD deleted from the database and no longer exist """ - _deletedAt: Int + _deletedAt: BigInt } enum SavedItemStatus { ARCHIVED @@ -262,7 +265,7 @@ type Tag @requiresScopes(scopes: [["ROLE_USER"]]) { """ Unix timestamp of when the entity was deleted, 30 days after this date this entity will be HARD deleted from the database and no longer exist """ - _deletedAt: Int + _deletedAt: BigInt } """ Input field for upserting a SavedItem @@ -280,7 +283,7 @@ input SavedItemUpsertInput { """ Optional, time that request was submitted by client epoch/unix time """ - timestamp: Int + timestamp: BigInt """ Optional, title of the SavedItem """ @@ -359,12 +362,12 @@ input SavedItemsFilter { Optional, filter to get SavedItems updated since a unix timestamp. Mutually exclusive with `updatedBefore` option. """ - updatedSince: Int + updatedSince: BigInt """ Optional, filter to get SavedItems updated before a unix timestamp. Mutually exclusive with `updatedSince` option. """ - updatedBefore: Int + updatedBefore: BigInt """ Optional, filter to get SavedItems that have been favorited """ diff --git a/servers/list-api/src/resolvers/index.ts b/servers/list-api/src/resolvers/index.ts index 1f5eff44b..dff55fd7c 100644 --- a/servers/list-api/src/resolvers/index.ts +++ b/servers/list-api/src/resolvers/index.ts @@ -46,8 +46,10 @@ import { IContext } from '../server/context'; import { PocketDefaultScalars } from '@pocket-tools/apollo-utils'; import { GraphQLResolveInfo } from 'graphql'; import { itemIdFromSlug } from '@pocket-tools/int-mask'; +import { scalarResolvers } from 'graphql-scalars'; const resolvers = { + ...scalarResolvers, ...PocketDefaultScalars, BaseError: { __resolveType(parent: BaseError) {