From dd4e4447f619dbcb62b8092873304c51d8ab0c21 Mon Sep 17 00:00:00 2001 From: aexol Date: Mon, 5 Aug 2024 17:58:29 +0200 Subject: [PATCH] version and scalars --- adapters/apollo-server/index.ts | 7 +- adapters/apollo-server/package-lock.json | 4 +- adapters/apollo-server/package.json | 4 +- adapters/graphql-yoga/index.ts | 7 +- adapters/graphql-yoga/package.json | 4 +- adapters/stucco/.eslintrc.json | 5 - adapters/stucco/.gitignore | 4 - adapters/stucco/index.ts | 66 --- adapters/stucco/jest.config.js | 10 - adapters/stucco/package.json | 20 - adapters/stucco/tsconfig.json | 44 -- deno.lock | 1 - docs/pages/adapters/stucco.mdx | 36 -- docs/pages/scalars.mdx | 3 + examples/beerpub-apollo-server/package.json | 8 +- examples/beerpub-apollo-server/src/axolotl.ts | 2 +- examples/beerpub-yoga-federated/package.json | 8 +- .../beerpub-yoga-federated/src/axolotl.ts | 5 +- examples/beerpub-yoga/beers.json | 27 -- examples/beerpub-yoga/package.json | 10 +- examples/beerpub-yoga/schema.graphql | 5 + examples/beerpub-yoga/src/axolotl.ts | 9 +- examples/beerpub-yoga/src/index.ts | 21 +- examples/beerpub-yoga/src/models.ts | 23 +- examples/beerpub-yoga/src/ormBeersFile.ts | 51 --- examples/beerpub-yoga/src/resolvers.ts | 1 + examples/beerpub-yoga/src/scalars.ts | 14 + modularium/cli/package.json | 4 +- modularium/playground/package.json | 4 +- modularium/root/package.json | 8 +- package-lock.json | 428 +++++++----------- package.json | 4 +- packages/cli/create/consts.ts | 7 +- packages/cli/package.json | 6 +- packages/config/package.json | 2 +- packages/core/gen.ts | 20 +- packages/core/index.ts | 13 +- packages/core/package.json | 2 +- packages/core/types.ts | 6 + tsconfig.json | 3 - 40 files changed, 289 insertions(+), 617 deletions(-) delete mode 100644 adapters/stucco/.eslintrc.json delete mode 100644 adapters/stucco/.gitignore delete mode 100644 adapters/stucco/index.ts delete mode 100644 adapters/stucco/jest.config.js delete mode 100644 adapters/stucco/package.json delete mode 100644 adapters/stucco/tsconfig.json delete mode 100644 docs/pages/adapters/stucco.mdx create mode 100644 docs/pages/scalars.mdx delete mode 100644 examples/beerpub-yoga/beers.json delete mode 100644 examples/beerpub-yoga/src/ormBeersFile.ts create mode 100644 examples/beerpub-yoga/src/scalars.ts diff --git a/adapters/apollo-server/index.ts b/adapters/apollo-server/index.ts index 05857eb..69f9cce 100644 --- a/adapters/apollo-server/index.ts +++ b/adapters/apollo-server/index.ts @@ -10,7 +10,7 @@ import { GraphQLSchema } from 'graphql'; type SchemaMapperInitial = Required>[1]; export type SchemaMapper = (schema: GraphQLSchema, getDirective: typeof getDirectiveFn) => SchemaMapperInitial; export const apolloServerAdapter = AxolotlAdapter<[any, any, any, any], SchemaMapper>()(( - { resolvers, directives }, + { resolvers, directives, scalars }, options?: { schema?: { file?: { path: string } | { content: string }; @@ -43,7 +43,10 @@ export const apolloServerAdapter = AxolotlAdapter<[any, any, any, any], SchemaMa let apolloSchema = makeExecutableSchema({ typeDefs: schema, - resolvers: apolloResolvers, + resolvers: { + ...apolloResolvers, + ...scalars, + }, }); if (directives) { diff --git a/adapters/apollo-server/package-lock.json b/adapters/apollo-server/package-lock.json index 479b9cb..26e3db4 100644 --- a/adapters/apollo-server/package-lock.json +++ b/adapters/apollo-server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aexol/axolotl-apollo-server", - "version": "0.4.4", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@aexol/axolotl-apollo-server", - "version": "0.4.4", + "version": "0.5.0", "dependencies": { "@aexol/axolotl-core": "^0.0.8", "@apollo/server": "^4.9.4", diff --git a/adapters/apollo-server/package.json b/adapters/apollo-server/package.json index 2eafa4f..1f01d47 100644 --- a/adapters/apollo-server/package.json +++ b/adapters/apollo-server/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/axolotl-apollo-server", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", @@ -14,7 +14,7 @@ "lib" ], "dependencies": { - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", "@apollo/server": "^4.9.4", "@graphql-tools/schema": "^9.0.19", "@graphql-tools/utils": "^9.2.1" diff --git a/adapters/graphql-yoga/index.ts b/adapters/graphql-yoga/index.ts index e312596..3391725 100644 --- a/adapters/graphql-yoga/index.ts +++ b/adapters/graphql-yoga/index.ts @@ -13,7 +13,7 @@ export type SchemaMapper = ( ) => SchemaMapperInitial; export const graphqlYogaAdapter = AxolotlAdapter<[any, any, YogaInitialContext], SchemaMapper>()(( - { resolvers, directives }, + { resolvers, directives, scalars }, options?: { yoga?: Parameters[0]; schema?: { @@ -48,7 +48,10 @@ export const graphqlYogaAdapter = AxolotlAdapter<[any, any, YogaInitialContext], let yogaSchema = createSchema({ ...options?.schema?.options, typeDefs: schema, - resolvers: yogaResolvers, + resolvers: { + ...yogaResolvers, + ...scalars, + }, }); if (directives) { diff --git a/adapters/graphql-yoga/package.json b/adapters/graphql-yoga/package.json index a038967..a3dbed3 100644 --- a/adapters/graphql-yoga/package.json +++ b/adapters/graphql-yoga/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/axolotl-graphql-yoga", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", @@ -14,7 +14,7 @@ "lib" ], "dependencies": { - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", "@graphql-tools/utils": "^10.3.2", "graphql-yoga": "^4.0.5" }, diff --git a/adapters/stucco/.eslintrc.json b/adapters/stucco/.eslintrc.json deleted file mode 100644 index 1719ce0..0000000 --- a/adapters/stucco/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "../../.eslintrc.json" - ] -} \ No newline at end of file diff --git a/adapters/stucco/.gitignore b/adapters/stucco/.gitignore deleted file mode 100644 index 964a3d0..0000000 --- a/adapters/stucco/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.env -/lib -/node_modules -.graphql-editor-auth.json \ No newline at end of file diff --git a/adapters/stucco/index.ts b/adapters/stucco/index.ts deleted file mode 100644 index d32a1fe..0000000 --- a/adapters/stucco/index.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -import { FieldResolveInput } from 'stucco-js'; -import { existsSync, readFileSync, writeFileSync } from 'fs'; -import * as path from 'path'; -import { AxolotlAdapter } from '@aexol/axolotl-core'; - -// eslint-disable-next-line @typescript-eslint/ban-types -export const stuccoAdapter = AxolotlAdapter()( - ({ resolvers }, production) => - (input: FieldResolveInput) => { - const field = input.info.fieldName; - const typeName = input.info.parentType; - const type = typeName ? ('name' in typeName ? typeName.name : undefined) : undefined; - - if (!production) { - updateStuccoJson(resolvers); - } - if (!type) return null; - if (!field) return null; - const typeResolver = resolvers[type]; - if (!typeResolver) { - throw new Error(`Cannot find resolver for type: "${type}"`); - } - const fieldResolver = typeResolver[field as keyof typeof typeResolver]; - if (!fieldResolver) { - throw new Error(`Cannot find resolver for type: "${type}" and field "${field}"`); - } - if (typeof fieldResolver !== 'function') { - throw new Error('Axolotl resolver must be a function'); - } - return fieldResolver(input, input.arguments); - }, -); - -export const updateStuccoJson = (resolvers: Record>) => { - const stuccoPath = path.join(process.cwd(), 'stucco.json'); - let currentStucco: { - resolvers?: { - [x: string]: { - resolve: { - name: string; - }; - }; - }; - } = {}; - if (existsSync(stuccoPath)) { - currentStucco = JSON.parse(readFileSync(stuccoPath, 'utf8')); - } - Object.entries(resolvers).map(([k, v]) => { - currentStucco.resolvers = {}; - if (v && typeof v === 'object') { - Object.entries(v).map(([key, fn]) => { - if (fn) { - const theKey = `${k}.${key}`; - currentStucco.resolvers ||= {}; - currentStucco.resolvers[theKey] = { - resolve: { - name: 'lib/index', - }, - }; - } - }); - } - }); - writeFileSync(path.join(process.cwd(), 'stucco.json'), JSON.stringify(currentStucco, null, 4)); -}; diff --git a/adapters/stucco/jest.config.js b/adapters/stucco/jest.config.js deleted file mode 100644 index 7125aee..0000000 --- a/adapters/stucco/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - preset: 'ts-jest', - moduleFileExtensions: ['ts', 'tsx', 'js'], - moduleNameMapper: { - '@/(.*)': ['/$1'], - }, - testMatch: ['/**/*.spec.(ts|tsx)'], - watchPathIgnorePatterns: ['node_modules'], - watchman: false, -}; diff --git a/adapters/stucco/package.json b/adapters/stucco/package.json deleted file mode 100644 index f0aab65..0000000 --- a/adapters/stucco/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "@aexol/axolotl-stucco", - "version": "0.4.5", - "private": false, - "main": "./lib/index.js", - "author": "Aexol, Artur Czemiel", - "type": "module", - "scripts": { - "build": "tspc", - "start": "tspc --watch", - "lint": "tspc && eslint \"./src/**/*.{ts,js}\" --quiet --fix" - }, - "files": [ - "lib" - ], - "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "stucco-js": "^0.10.19" - } -} diff --git a/adapters/stucco/tsconfig.json b/adapters/stucco/tsconfig.json deleted file mode 100644 index 43b9f43..0000000 --- a/adapters/stucco/tsconfig.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "compilerOptions": { - "sourceMap": true, - "target": "es2022", - "module": "es2022", - "moduleResolution": "node", - "experimentalDecorators": true, - "declaration": true, - "incremental": true, - "removeComments": true, - "noUnusedLocals": true, - "strictNullChecks": true, - "skipLibCheck": true, - "strict": true, - "outDir": "./lib", - "lib": [ - "ESNext", - "DOM", - "DOM.Iterable" - ], - "rootDir": "./", - "baseUrl": "./", - "composite": true, - "paths": { - "@/*": [ - "./*" - ] - }, - "plugins": [ - { - "transform": "typescript-transform-paths" - }, - { - "transform": "typescript-transform-paths", - "afterDeclarations": true - } - ] - }, - "exclude": [ - "lib", - "node_modules", - "jest.config.js" - ] -} \ No newline at end of file diff --git a/deno.lock b/deno.lock index 506b3d1..20c3c65 100644 --- a/deno.lock +++ b/deno.lock @@ -234,7 +234,6 @@ "npm:node-fetch@^3.2.10", "npm:prettier@^3.3.0", "npm:sass@^1.69.3", - "npm:stucco-js@^0.10.19", "npm:ts-node@^10.9.1", "npm:ts-patch@^3.0.0", "npm:typescript-transform-paths@^3.4.6", diff --git a/docs/pages/adapters/stucco.mdx b/docs/pages/adapters/stucco.mdx deleted file mode 100644 index aef82ac..0000000 --- a/docs/pages/adapters/stucco.mdx +++ /dev/null @@ -1,36 +0,0 @@ -# Stucco - -Install adapter - -```sh -npm i @aexol/axolotl-stucco stucco-js -``` - -Then write your `index.ts` file. In stucco the default export of the file is the -router. Stucco will also generate `stucco.json` file every time you change the -code. This file is used by the stucco GoLang router. - -```ts filename="axolotl.ts" -import { Axolotl } from '@aexol/axolotl-core'; -import { stuccoAdapter } from '@aexol/axolotl-stucco'; -import { Models } from '@/src/models.js'; - -export const { applyMiddleware, createResolvers, adapter } = Axolotl(stuccoAdapter)(); -``` - -```ts filename="resolvers.ts" -export default createResolvers({ - // your type-safe resolvers here -}); -``` - -```ts filename="index.ts" -import { FieldResolveInput } from 'stucco-js'; -import { adapter } from '@/src/axolotl.js'; -import resolvers from '@/src/resolvers.js'; - - -export default async (input: FieldResolveInput) => { - return adapter({resolvers})(input); -}; -``` diff --git a/docs/pages/scalars.mdx b/docs/pages/scalars.mdx new file mode 100644 index 0000000..5e02fa5 --- /dev/null +++ b/docs/pages/scalars.mdx @@ -0,0 +1,3 @@ +# Custom scalars + +Custom scalar resolvers work like any other resolvers \ No newline at end of file diff --git a/examples/beerpub-apollo-server/package.json b/examples/beerpub-apollo-server/package.json index b844404..6cbe5ea 100644 --- a/examples/beerpub-apollo-server/package.json +++ b/examples/beerpub-apollo-server/package.json @@ -1,6 +1,6 @@ { "name": "beerpub-apollo-server", - "version": "0.4.5", + "version": "0.5.0", "description": "Automatically generated by graphql-editor-cli", "main": "lib/index.js", "type": "module", @@ -17,15 +17,15 @@ "author": "GraphQL Editor Centaur Generator", "license": "ISC", "dependencies": { - "@aexol/axolotl-apollo-server": "^0.4.5", - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-apollo-server": "^0.5.0", + "@aexol/axolotl-core": "^0.5.0", "@apollo/server": "^4.9.4", "graphql": "^16.8.1", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^6.16.0", "@typescript-eslint/parser": "^6.16.0", diff --git a/examples/beerpub-apollo-server/src/axolotl.ts b/examples/beerpub-apollo-server/src/axolotl.ts index 2f45e5e..3c87c6e 100644 --- a/examples/beerpub-apollo-server/src/axolotl.ts +++ b/examples/beerpub-apollo-server/src/axolotl.ts @@ -2,5 +2,5 @@ import { Models } from "@/src/models.js"; import { Axolotl } from "@aexol/axolotl-core"; import { apolloServerAdapter } from "@aexol/axolotl-apollo-server"; -export const { applyMiddleware, createResolvers, adapter } = Axolotl(apolloServerAdapter)(); +export const { applyMiddleware, createResolvers, adapter } = Axolotl(apolloServerAdapter)(); \ No newline at end of file diff --git a/examples/beerpub-yoga-federated/package.json b/examples/beerpub-yoga-federated/package.json index 9a0ec40..65552ae 100644 --- a/examples/beerpub-yoga-federated/package.json +++ b/examples/beerpub-yoga-federated/package.json @@ -1,6 +1,6 @@ { "name": "beerpub-yoga-federated", - "version": "0.5.5", + "version": "0.6.0", "description": "Automatically generated by graphql-editor-cli", "main": "lib/index.js", "type": "module", @@ -20,15 +20,15 @@ "author": "GraphQL Editor Centaur Generator", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "graphql": "^16.8.1", "graphql-yoga": "^4.0.5", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", "@typescript-eslint/parser": "^7.12.0", diff --git a/examples/beerpub-yoga-federated/src/axolotl.ts b/examples/beerpub-yoga-federated/src/axolotl.ts index 66d60db..eb7abbd 100644 --- a/examples/beerpub-yoga-federated/src/axolotl.ts +++ b/examples/beerpub-yoga-federated/src/axolotl.ts @@ -2,7 +2,4 @@ import { Models } from '@/src/models.js'; import { Axolotl } from '@aexol/axolotl-core'; import { graphqlYogaAdapter } from '@aexol/axolotl-graphql-yoga'; -export const { applyMiddleware, createResolvers, createDirectives, adapter } = Axolotl(graphqlYogaAdapter)< - Models, - unknown ->(); +export const { applyMiddleware, createResolvers, createDirectives, adapter } = Axolotl(graphqlYogaAdapter)(); diff --git a/examples/beerpub-yoga/beers.json b/examples/beerpub-yoga/beers.json deleted file mode 100644 index 0a476ba..0000000 --- a/examples/beerpub-yoga/beers.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - { - "_id": "0.30130727223450351", - "createdAt": "2023-10-10T15:21:43.038Z", - "name": "Kumple", - "price": 10, - "info": "Dobre piwko" - }, - { - "_id": "0.31745026457263467", - "createdAt": "2023-10-11T14:51:09.029Z", - "name": "Zubr", - "price": 100 - }, - { - "_id": "0.510243671657007454", - "createdAt": "2023-10-12T15:03:56.018Z", - "name": "Tyskie", - "price": 111 - }, - { - "_id": "0.072526223635653174", - "createdAt": "2023-10-18T09:08:25.441Z", - "name": "Debowe", - "price": 100 - } -] \ No newline at end of file diff --git a/examples/beerpub-yoga/package.json b/examples/beerpub-yoga/package.json index afa1519..84fa3a0 100644 --- a/examples/beerpub-yoga/package.json +++ b/examples/beerpub-yoga/package.json @@ -1,6 +1,6 @@ { "name": "beerpub-yoga", - "version": "0.5.5", + "version": "0.6.0", "description": "Automatically generated by graphql-editor-cli", "main": "lib/index.js", "type": "module", @@ -20,15 +20,15 @@ "author": "GraphQL Editor Centaur Generator", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "graphql": "^16.8.1", - "graphql-yoga": "^4.0.5", + "graphql-yoga": "^5.6.3", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", "@typescript-eslint/parser": "^7.12.0", diff --git a/examples/beerpub-yoga/schema.graphql b/examples/beerpub-yoga/schema.graphql index 6a5633e..f596159 100644 --- a/examples/beerpub-yoga/schema.graphql +++ b/examples/beerpub-yoga/schema.graphql @@ -4,6 +4,7 @@ type Beer implements Node{ _id: String! createdAt: String! info:String + url: URL } type Query{ @@ -27,6 +28,7 @@ type Mutation{ input CreateBeer{ name: String! price: Int! + url: URL } interface Node{ @@ -37,6 +39,7 @@ interface Node{ input UpdateBeer{ name: String price: Int + url: URL } schema{ @@ -44,4 +47,6 @@ schema{ mutation: Mutation } + +scalar URL directive @auth on FIELD_DEFINITION \ No newline at end of file diff --git a/examples/beerpub-yoga/src/axolotl.ts b/examples/beerpub-yoga/src/axolotl.ts index 2068e09..04e21da 100644 --- a/examples/beerpub-yoga/src/axolotl.ts +++ b/examples/beerpub-yoga/src/axolotl.ts @@ -1,8 +1,7 @@ -import { Directives, Models } from '@/src/models.js'; +import { Directives, Models, Scalars } from '@/src/models.js'; import { Axolotl } from '@aexol/axolotl-core'; import { graphqlYogaAdapter } from '@aexol/axolotl-graphql-yoga'; -export const { applyMiddleware, createResolvers, createDirectives, adapter } = Axolotl(graphqlYogaAdapter)< - Models, - Directives ->(); +export const { applyMiddleware, createResolvers, createDirectives, adapter, createScalars } = Axolotl( + graphqlYogaAdapter, +)(); diff --git a/examples/beerpub-yoga/src/index.ts b/examples/beerpub-yoga/src/index.ts index 9ff5d8b..bd10b52 100644 --- a/examples/beerpub-yoga/src/index.ts +++ b/examples/beerpub-yoga/src/index.ts @@ -1,19 +1,12 @@ -import { adapter, applyMiddleware } from '@/src/axolotl.js'; +import { adapter } from '@/src/axolotl.js'; import resolvers from '@/src/resolvers.js'; import directives from '@/src/directives.js'; +import scalars from '@/src/scalars.js'; -// This is yoga specific -applyMiddleware( +adapter({ resolvers, - [ - (input) => { - console.log('Hello from Middleware I run only on Query.beers'); - return input; - }, - ], - { Query: { beers: true } }, -); - -adapter({ resolvers, directives }).server.listen(parseInt(process.env.PORT || '4000'), () => { - console.log('LISTENING to ' + process.env.PORT || '4000'); + scalars, + directives, +}).server.listen(parseInt(process.env.PORT || '4002'), () => { + console.log('LISTENING to ' + process.env.PORT || '4002'); }); diff --git a/examples/beerpub-yoga/src/models.ts b/examples/beerpub-yoga/src/models.ts index 6b011fd..118e500 100644 --- a/examples/beerpub-yoga/src/models.ts +++ b/examples/beerpub-yoga/src/models.ts @@ -1,10 +1,14 @@ +export type URL = unknown; + export interface CreateBeer { name: string; price: number; + url?: URL | undefined; } export interface UpdateBeer { name?: string | undefined; price?: number | undefined; + url?: URL | undefined; } export type Models = { @@ -24,6 +28,9 @@ export type Models = { info: { args: Record; }; + url: { + args: Record; + }; }; ['Query']: { beers: { @@ -54,9 +61,18 @@ export type Models = { }; export type Directives = { - auth: { - args: Record; - }; + auth: { + args: Record; + }; +}; + +export interface Node { + _id: string; + createdAt: string; +} + +export type Scalars = { + ['URL']: unknown; }; export interface Beer { @@ -65,6 +81,7 @@ export interface Beer { _id: string; createdAt: string; info?: string | undefined; + url?: URL | undefined; } export interface Query { beers?: Array | undefined; diff --git a/examples/beerpub-yoga/src/ormBeersFile.ts b/examples/beerpub-yoga/src/ormBeersFile.ts deleted file mode 100644 index a24201b..0000000 --- a/examples/beerpub-yoga/src/ormBeersFile.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { readFileSync, writeFileSync } from 'fs'; -import path from 'path'; - -type Beer = { - name: string; - price: number; - _id: string; - createdAt: string; -}; - -const beerFilePath = path.join(process.cwd(), 'beers.json'); -const beers: Array = JSON.parse(readFileSync(beerFilePath, 'utf-8')); - -export const BeerOrm = () => { - const write = () => { - writeFileSync(beerFilePath, JSON.stringify(beers)); - }; - const create = (beer: Pick) => { - const beerId = Math.random().toString(8); - beers.push({ - _id: beerId, - createdAt: new Date().toISOString(), - ...beer, - }); - write(); - return beerId; - }; - const remove = (beer: Pick) => { - const deletedIndex = beers.findIndex((b) => b._id === beer._id); - beers.splice(deletedIndex, 1); - write(); - return true; - }; - const update = (_id: string, beer: Partial>) => { - const updatedIndex = beers.findIndex((b) => b._id === _id); - beers[updatedIndex] = { - ...beers[updatedIndex], - ...beer, - }; - return true; - }; - const list = () => { - return JSON.parse(readFileSync(beerFilePath, 'utf-8')) as Beer[]; - }; - return { - create, - update, - remove, - list, - }; -}; diff --git a/examples/beerpub-yoga/src/resolvers.ts b/examples/beerpub-yoga/src/resolvers.ts index b61701b..01bf1ae 100644 --- a/examples/beerpub-yoga/src/resolvers.ts +++ b/examples/beerpub-yoga/src/resolvers.ts @@ -14,6 +14,7 @@ const Beers: Beer[] = [ createdAt: '2023-10-11T14:51:09.029Z', name: 'Zubr', price: 100, + url: 'https://zubr.pl', }, ]; diff --git a/examples/beerpub-yoga/src/scalars.ts b/examples/beerpub-yoga/src/scalars.ts new file mode 100644 index 0000000..f7755b5 --- /dev/null +++ b/examples/beerpub-yoga/src/scalars.ts @@ -0,0 +1,14 @@ +import { createScalars } from '@/src/axolotl.js'; +import { GraphQLScalarType } from 'graphql'; + +export default createScalars({ + URL: new GraphQLScalarType({ + name: 'URL', + serialize(value) { + return new URL((value as string).toString()).toString(); + }, + parseValue(value) { + return value === null ? value : new URL(value as string); + }, + }), +}); diff --git a/modularium/cli/package.json b/modularium/cli/package.json index f9ac7ea..b893ecb 100644 --- a/modularium/cli/package.json +++ b/modularium/cli/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/modularium", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", @@ -17,7 +17,7 @@ "lib" ], "dependencies": { - "@aexol/axolotl-config": "^0.4.5", + "@aexol/axolotl-config": "^0.5.0", "chalk": "^5.3.0", "commander": "^11.0.0" } diff --git a/modularium/playground/package.json b/modularium/playground/package.json index c74f752..002ca0b 100644 --- a/modularium/playground/package.json +++ b/modularium/playground/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/modularium-playground", - "version": "0.4.5", + "version": "0.5.0", "description": "Axolotl modularium", "main": "lib/index.js", "type": "module", @@ -14,6 +14,6 @@ "author": "GraphQL Editor Centaur Generator", "license": "ISC", "devDependencies": { - "@aexol/modularium": "^0.4.5" + "@aexol/modularium": "^0.5.0" } } diff --git a/modularium/root/package.json b/modularium/root/package.json index d474de2..2f9d2d2 100644 --- a/modularium/root/package.json +++ b/modularium/root/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/modularium-root", - "version": "0.4.5", + "version": "0.5.0", "description": "Axolotl modularium", "main": "lib/index.js", "type": "module", @@ -20,8 +20,8 @@ "author": "GraphQL Editor Centaur Generator", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "googleapis": "^140.0.1", "graphql": "^16.8.1", "graphql-yoga": "^4.0.5", @@ -32,7 +32,7 @@ "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", diff --git a/package-lock.json b/package-lock.json index d6097dd..c166f59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,6 @@ "workspaces": [ "packages/config", "packages/core", - "adapters/stucco", "adapters/graphql-yoga", "adapters/apollo-server", "packages/cli", @@ -25,7 +24,6 @@ "dependencies": { "node-fetch": "^3.2.10", "sass": "^1.69.3", - "stucco-js": "^0.10.19", "ws": "^8.12.0" }, "devDependencies": { @@ -50,9 +48,9 @@ }, "adapters/apollo-server": { "name": "@aexol/axolotl-apollo-server", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", "@apollo/server": "^4.9.4", "@graphql-tools/schema": "^9.0.19", "@graphql-tools/utils": "^9.2.1" @@ -172,9 +170,9 @@ }, "adapters/graphql-yoga": { "name": "@aexol/axolotl-graphql-yoga", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", "@graphql-tools/utils": "^10.3.2", "graphql-yoga": "^4.0.5" }, @@ -182,27 +180,19 @@ "graphql": "^16.0.0 || ^17.0.0" } }, - "adapters/stucco": { - "name": "@aexol/axolotl-stucco", - "version": "0.4.5", - "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "stucco-js": "^0.10.19" - } - }, "examples/beerpub-apollo-server": { - "version": "0.4.5", + "version": "0.5.0", "license": "ISC", "dependencies": { - "@aexol/axolotl-apollo-server": "^0.4.5", - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-apollo-server": "^0.5.0", + "@aexol/axolotl-core": "^0.5.0", "@apollo/server": "^4.9.4", "graphql": "^16.8.1", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^6.16.0", "@typescript-eslint/parser": "^6.16.0", @@ -554,18 +544,18 @@ } }, "examples/beerpub-yoga": { - "version": "0.5.5", + "version": "0.6.0", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "graphql": "^16.8.1", - "graphql-yoga": "^4.0.5", + "graphql-yoga": "^5.6.3", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", "@typescript-eslint/parser": "^7.12.0", @@ -580,18 +570,18 @@ } }, "examples/beerpub-yoga-federated": { - "version": "0.5.5", + "version": "0.6.0", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "graphql": "^16.8.1", "graphql-yoga": "^4.0.5", "node-fetch": "^3.2.10", "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", "@typescript-eslint/parser": "^7.12.0", @@ -613,11 +603,95 @@ "graphql": "^16.0.0 || ^17.0.0" } }, + "examples/beerpub-yoga/node_modules/@envelop/core": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@envelop/core/-/core-5.0.1.tgz", + "integrity": "sha512-wxA8EyE1fPnlbP0nC/SFI7uU8wSNf4YjxZhAPu0P63QbgIvqHtHsH4L3/u+rsTruzhk3OvNRgQyLsMfaR9uzAQ==", + "dependencies": { + "@envelop/types": "5.0.0", + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "examples/beerpub-yoga/node_modules/@envelop/types": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@envelop/types/-/types-5.0.0.tgz", + "integrity": "sha512-IPjmgSc4KpQRlO4qbEDnBEixvtb06WDmjKfi/7fkZaryh5HuOmTtixe1EupQI5XfXO8joc3d27uUZ0QdC++euA==", + "dependencies": { + "tslib": "^2.5.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "examples/beerpub-yoga/node_modules/@graphql-yoga/logger": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@graphql-yoga/logger/-/logger-2.0.0.tgz", + "integrity": "sha512-Mg8psdkAp+YTG1OGmvU+xa6xpsAmSir0hhr3yFYPyLNwzUj95DdIwsMpKadDj9xDpYgJcH3Hp/4JMal9DhQimA==", + "dependencies": { + "tslib": "^2.5.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "examples/beerpub-yoga/node_modules/@graphql-yoga/subscription": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/@graphql-yoga/subscription/-/subscription-5.0.1.tgz", + "integrity": "sha512-1wCB1DfAnaLzS+IdoOzELGGnx1ODEg9nzQXFh4u2j02vAnne6d+v4A7HIH9EqzVdPLoAaMKXCZUUdKs+j3z1fg==", + "dependencies": { + "@graphql-yoga/typed-event-target": "^3.0.0", + "@repeaterjs/repeater": "^3.0.4", + "@whatwg-node/events": "^0.1.0", + "tslib": "^2.5.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "examples/beerpub-yoga/node_modules/@graphql-yoga/typed-event-target": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@graphql-yoga/typed-event-target/-/typed-event-target-3.0.0.tgz", + "integrity": "sha512-w+liuBySifrstuHbFrHoHAEyVnDFVib+073q8AeAJ/qqJfvFvAwUPLLtNohR/WDVRgSasfXtl3dcNuVJWN+rjg==", + "dependencies": { + "@repeaterjs/repeater": "^3.0.4", + "tslib": "^2.5.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "examples/beerpub-yoga/node_modules/graphql-yoga": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/graphql-yoga/-/graphql-yoga-5.6.3.tgz", + "integrity": "sha512-JtZ3r/QdkGpdi+8XfPuG+6Nb+V5wNMg2LYChSIATes5LhcIx3pbOkm/nWoGT/SA5LqlRyp+e0sxmVNEz8qN5TQ==", + "dependencies": { + "@envelop/core": "^5.0.1", + "@graphql-tools/executor": "^1.3.0", + "@graphql-tools/schema": "^10.0.4", + "@graphql-tools/utils": "^10.3.2", + "@graphql-yoga/logger": "^2.0.0", + "@graphql-yoga/subscription": "^5.0.1", + "@whatwg-node/fetch": "^0.9.18", + "@whatwg-node/server": "^0.9.41", + "dset": "^3.1.1", + "lru-cache": "^10.0.0", + "tslib": "^2.5.2" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "graphql": "^15.2.0 || ^16.0.0" + } + }, "modularium/cli": { "name": "@aexol/modularium", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { - "@aexol/axolotl-config": "^0.4.5", + "@aexol/axolotl-config": "^0.5.0", "chalk": "^5.3.0", "commander": "^11.0.0" }, @@ -637,19 +711,19 @@ }, "modularium/playground": { "name": "@aexol/modularium-playground", - "version": "0.4.5", + "version": "0.5.0", "license": "ISC", "devDependencies": { - "@aexol/modularium": "^0.4.5" + "@aexol/modularium": "^0.5.0" } }, "modularium/root": { "name": "@aexol/modularium-root", - "version": "0.4.5", + "version": "0.5.0", "license": "ISC", "dependencies": { - "@aexol/axolotl-core": "^0.4.5", - "@aexol/axolotl-graphql-yoga": "^0.4.5", + "@aexol/axolotl-core": "^0.5.0", + "@aexol/axolotl-graphql-yoga": "^0.5.0", "googleapis": "^140.0.1", "graphql": "^16.8.1", "graphql-yoga": "^4.0.5", @@ -660,7 +734,7 @@ "ws": "^8.12.0" }, "devDependencies": { - "@aexol/axolotl": "^0.4.5", + "@aexol/axolotl": "^0.5.0", "@types/jsonwebtoken": "^9.0.6", "@types/node": "^18.7.18", "@typescript-eslint/eslint-plugin": "^7.12.0", @@ -703,10 +777,6 @@ "resolved": "adapters/graphql-yoga", "link": true }, - "node_modules/@aexol/axolotl-stucco": { - "resolved": "adapters/stucco", - "link": true - }, "node_modules/@aexol/modularium": { "resolved": "modularium/cli", "link": true @@ -1674,10 +1744,11 @@ } }, "node_modules/@graphql-tools/executor": { - "version": "1.2.0", - "license": "MIT", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@graphql-tools/executor/-/executor-1.3.0.tgz", + "integrity": "sha512-e+rmEf/2EO4hDnbkO8mTS2FI+jGUNmYkSDKw5TgPVlO8VOKS+TXmJBK6E9v4Gc/39yVkZsffYfW/R8obJrA0mg==", "dependencies": { - "@graphql-tools/utils": "^10.0.0", + "@graphql-tools/utils": "^10.2.3", "@graphql-typed-document-node/core": "3.2.0", "@repeaterjs/repeater": "^3.0.4", "tslib": "^2.4.0", @@ -1777,33 +1848,6 @@ "node": ">=16.0.0" } }, - "node_modules/@grpc/grpc-js": { - "version": "1.9.6", - "license": "Apache-2.0", - "dependencies": { - "@grpc/proto-loader": "^0.7.8", - "@types/node": ">=12.12.47" - }, - "engines": { - "node": "^8.13.0 || >=10.10.0" - } - }, - "node_modules/@grpc/proto-loader": { - "version": "0.7.10", - "license": "Apache-2.0", - "dependencies": { - "lodash.camelcase": "^4.3.0", - "long": "^5.0.0", - "protobufjs": "^7.2.4", - "yargs": "^17.7.2" - }, - "bin": { - "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "dev": true, @@ -2302,6 +2346,11 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@kamilkisiela/fast-url-parser": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@kamilkisiela/fast-url-parser/-/fast-url-parser-1.1.4.tgz", + "integrity": "sha512-gbkePEBupNydxCelHCESvFSFM8XPh1Zs/OAVRW/rKpEqPAl5PbOM90Si8mv9bvnR53uPD2s/FiRxdvSejpRJew==" + }, "node_modules/@ljharb/through": { "version": "2.3.13", "license": "MIT", @@ -2877,39 +2926,41 @@ } }, "node_modules/@whatwg-node/fetch": { - "version": "0.9.13", - "license": "MIT", + "version": "0.9.19", + "resolved": "https://registry.npmjs.org/@whatwg-node/fetch/-/fetch-0.9.19.tgz", + "integrity": "sha512-J+zopRcUVOhkiQYlHpxOEZuOgZtqW9xMaNQFDjESm9vRcyATms+E2/p2mZiVQGllPqWflkA3SzoJC1MxV4Pf9g==", "dependencies": { - "@whatwg-node/node-fetch": "^0.4.17", - "urlpattern-polyfill": "^9.0.0" + "@whatwg-node/node-fetch": "^0.5.16", + "urlpattern-polyfill": "^10.0.0" }, "engines": { "node": ">=16.0.0" } }, "node_modules/@whatwg-node/node-fetch": { - "version": "0.4.19", - "license": "MIT", + "version": "0.5.20", + "resolved": "https://registry.npmjs.org/@whatwg-node/node-fetch/-/node-fetch-0.5.20.tgz", + "integrity": "sha512-DFLsOG//CrDdIO0x7Q7Ompxj3TZhB4iMDeXpQKY4toSbIbzsKmbwyOkzXMwvV1syxvAtPoHBzyGGtDrPV424FA==", "dependencies": { - "@whatwg-node/events": "^0.1.0", + "@kamilkisiela/fast-url-parser": "^1.1.4", "busboy": "^1.6.0", "fast-querystring": "^1.1.1", - "fast-url-parser": "^1.1.3", - "tslib": "^2.3.1" + "tslib": "^2.6.3" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } }, "node_modules/@whatwg-node/server": { - "version": "0.9.15", - "license": "MIT", + "version": "0.9.46", + "resolved": "https://registry.npmjs.org/@whatwg-node/server/-/server-0.9.46.tgz", + "integrity": "sha512-vUKCMPP6f2BLtOxnK2c98QmK0rb24RlmXb2enbEg8nXttQLvlKfMOfaY7uNAtaMXejjR2ku/ww9EEeiWXV3Q9A==", "dependencies": { - "@whatwg-node/fetch": "^0.9.10", - "tslib": "^2.3.1" + "@whatwg-node/fetch": "^0.9.19", + "tslib": "^2.6.3" }, "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" } }, "node_modules/abbrev": { @@ -3368,35 +3419,6 @@ "node": "*" } }, - "node_modules/bin-version": { - "version": "6.0.0", - "license": "MIT", - "dependencies": { - "execa": "^5.0.0", - "find-versions": "^5.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/bin-version-check": { - "version": "5.1.0", - "license": "MIT", - "dependencies": { - "bin-version": "^6.0.0", - "semver": "^7.5.3", - "semver-truncate": "^3.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "license": "MIT", @@ -3555,6 +3577,8 @@ }, "node_modules/busboy": { "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "dependencies": { "streamsearch": "^1.1.0" }, @@ -4734,7 +4758,8 @@ }, "node_modules/fast-decode-uri-component": { "version": "1.0.1", - "license": "MIT" + "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", + "integrity": "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==" }, "node_modules/fast-deep-equal": { "version": "3.1.3", @@ -4781,18 +4806,12 @@ }, "node_modules/fast-querystring": { "version": "1.1.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/fast-querystring/-/fast-querystring-1.1.2.tgz", + "integrity": "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==", "dependencies": { "fast-decode-uri-component": "^1.0.1" } }, - "node_modules/fast-url-parser": { - "version": "1.1.3", - "license": "MIT", - "dependencies": { - "punycode": "^1.3.2" - } - }, "node_modules/fastq": { "version": "1.15.0", "license": "ISC", @@ -4916,19 +4935,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/find-versions": { - "version": "5.1.0", - "license": "MIT", - "dependencies": { - "semver-regex": "^4.0.5" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/flat-cache": { "version": "3.1.1", "dev": true, @@ -5361,10 +5367,6 @@ "safe-buffer": "^5.0.1" } }, - "node_modules/google-protobuf": { - "version": "3.21.2", - "license": "(BSD-3-Clause AND Apache-2.0)" - }, "node_modules/googleapis": { "version": "140.0.1", "license": "Apache-2.0", @@ -5465,23 +5467,6 @@ "graphql": "^15.2.0 || ^16.0.0" } }, - "node_modules/grpc-boom": { - "version": "1.0.29", - "license": "BSD-3-Clause" - }, - "node_modules/grpc-health-check-ts": { - "version": "1.0.2", - "license": "ISC", - "dependencies": { - "@grpc/grpc-js": "^1.3.6", - "grpc-boom": "^1.0.28", - "grpc-web": "^1.2.1" - } - }, - "node_modules/grpc-web": { - "version": "1.4.2", - "license": "Apache-2.0" - }, "node_modules/gtoken": { "version": "7.1.0", "license": "MIT", @@ -6906,10 +6891,6 @@ "version": "4.17.21", "license": "MIT" }, - "node_modules/lodash.camelcase": { - "version": "4.3.0", - "license": "MIT" - }, "node_modules/lodash.defaults": { "version": "4.2.0", "license": "MIT" @@ -6998,10 +6979,6 @@ "url": "https://tidelift.com/funding/github/npm/loglevel" } }, - "node_modules/long": { - "version": "5.2.3", - "license": "Apache-2.0" - }, "node_modules/lru-cache": { "version": "10.0.1", "license": "ISC", @@ -7355,6 +7332,7 @@ }, "node_modules/node-forge": { "version": "1.3.1", + "dev": true, "license": "(BSD-3-Clause OR GPL-2.0)", "engines": { "node": ">= 6.13.0" @@ -8077,28 +8055,6 @@ "node": ">= 6" } }, - "node_modules/protobufjs": { - "version": "7.2.5", - "hasInstallScript": true, - "license": "BSD-3-Clause", - "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" - }, - "engines": { - "node": ">=12.0.0" - } - }, "node_modules/proxy-addr": { "version": "2.0.7", "license": "MIT", @@ -8123,10 +8079,6 @@ "once": "^1.3.1" } }, - "node_modules/punycode": { - "version": "1.4.1", - "license": "MIT" - }, "node_modules/pure-rand": { "version": "6.0.4", "dev": true, @@ -8490,29 +8442,6 @@ "node": ">=10" } }, - "node_modules/semver-regex": { - "version": "4.0.5", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/semver-truncate": { - "version": "3.0.0", - "license": "MIT", - "dependencies": { - "semver": "^7.3.5" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/send": { "version": "0.18.0", "license": "MIT", @@ -8767,6 +8696,8 @@ }, "node_modules/streamsearch": { "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", "engines": { "node": ">=10.0.0" } @@ -8905,50 +8836,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/stucco-js": { - "version": "0.10.19", - "license": "MIT", - "dependencies": { - "@grpc/grpc-js": "^1.3.7", - "bin-version-check": "^5.0.0", - "google-protobuf": "^3.18.0", - "grpc-health-check-ts": "^1.0.2", - "lru-cache": "^6.0.0", - "node-forge": "^1.3.1", - "retry": "^0.13.1", - "stucco-ts-proto-gen": "^0.7.21", - "uuid": "^8.3.2", - "yargs": "^17.2.1" - }, - "bin": { - "stucco": "lib/stucco/cmd.js", - "stucco-js": "lib/cli/cli.js", - "stucco-js.cmd": "lib/cli/cli.cmd", - "stucco.cmd": "lib/stucco/cmd.cmd" - } - }, - "node_modules/stucco-js/node_modules/lru-cache": { - "version": "6.0.0", - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/stucco-js/node_modules/yallist": { - "version": "4.0.0", - "license": "ISC" - }, - "node_modules/stucco-ts-proto-gen": { - "version": "0.7.21", - "license": "ISC", - "dependencies": { - "@grpc/grpc-js": "^1.4.1", - "grpc-web": "^1.3.0" - } - }, "node_modules/supports-color": { "version": "7.2.0", "license": "MIT", @@ -9190,8 +9077,9 @@ } }, "node_modules/tslib": { - "version": "2.6.2", - "license": "0BSD" + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==" }, "node_modules/type-check": { "version": "0.4.0", @@ -9327,8 +9215,9 @@ "license": "BSD" }, "node_modules/urlpattern-polyfill": { - "version": "9.0.0", - "license": "MIT" + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-10.0.0.tgz", + "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==" }, "node_modules/util-deprecate": { "version": "1.0.2", @@ -9341,13 +9230,6 @@ "node": ">= 0.4.0" } }, - "node_modules/uuid": { - "version": "8.3.2", - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "license": "MIT" @@ -9761,10 +9643,10 @@ }, "packages/cli": { "name": "@aexol/axolotl", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { - "@aexol/axolotl-config": "^0.4.5", - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-config": "^0.5.0", + "@aexol/axolotl-core": "^0.5.0", "chalk": "^5.3.0", "chokidar": "^3.6.0", "commander": "^11.0.0", @@ -9786,7 +9668,7 @@ }, "packages/config": { "name": "@aexol/axolotl-config", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { "config-maker": "^0.0.6" } @@ -9941,7 +9823,7 @@ }, "packages/core": { "name": "@aexol/axolotl-core", - "version": "0.4.5", + "version": "0.5.0", "dependencies": { "@graphql-tools/utils": "^10.3.2", "graphql-js-tree": "^3.0.0" diff --git a/package.json b/package.json index 541bf6c..1fab8fb 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "dependencies": { "node-fetch": "^3.2.10", "sass": "^1.69.3", - "stucco-js": "^0.10.19", "ws": "^8.12.0" }, "repository": { @@ -41,7 +40,6 @@ "workspaces": [ "packages/config", "packages/core", - "adapters/stucco", "adapters/graphql-yoga", "adapters/apollo-server", "packages/cli", @@ -52,4 +50,4 @@ "examples/beerpub-yoga-federated", "examples/beerpub-apollo-server" ] -} \ No newline at end of file +} diff --git a/packages/cli/create/consts.ts b/packages/cli/create/consts.ts index 0a1e546..dfcee74 100644 --- a/packages/cli/create/consts.ts +++ b/packages/cli/create/consts.ts @@ -10,14 +10,9 @@ type T = { }; }; -export type STARTERS = 'stucco' | 'yoga' | 'apollo' | 'deno-yoga'; +export type STARTERS = 'yoga' | 'apollo' | 'deno-yoga'; export const STARTER_DICT: T = { - stucco: { - example: 'examples/beerpub', - repo: 'axolotl-starter-stucco', - description: 'stucco.js starter', - }, yoga: { example: 'examples/beerpub-yoga', repo: 'axolotl-starter-yoga', diff --git a/packages/cli/package.json b/packages/cli/package.json index 35d195e..3277d5b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/axolotl", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", @@ -17,8 +17,8 @@ "lib" ], "dependencies": { - "@aexol/axolotl-config": "^0.4.5", - "@aexol/axolotl-core": "^0.4.5", + "@aexol/axolotl-config": "^0.5.0", + "@aexol/axolotl-core": "^0.5.0", "chalk": "^5.3.0", "chokidar": "^3.6.0", "commander": "^11.0.0", diff --git a/packages/config/package.json b/packages/config/package.json index 67f8fac..cd50314 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/axolotl-config", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", diff --git a/packages/core/gen.ts b/packages/core/gen.ts index 360e234..537d3b5 100644 --- a/packages/core/gen.ts +++ b/packages/core/gen.ts @@ -72,7 +72,7 @@ const generateModelsString = (fileContent: string) => { const { nodes } = Parser.parse(fileContent); const scalars = nodes.filter((n) => n.data.type === TypeDefinition.ScalarTypeDefinition); - const scalarsString = scalars.map((s) => `export type ${s.name} = unknown`).join('\n'); + const scalarsString = scalars.map((s) => `export type ${s.name} = unknown;`).join('\n'); const enums = nodes.filter((n) => n.data.type === TypeDefinition.EnumTypeDefinition); const enumsString = enums.map((s) => `export enum ${s.name} ${buildEnumArgs(s.args)}`).join('\n'); @@ -113,16 +113,28 @@ const generateModelsString = (fileContent: string) => { const directives = nodes.filter((n) => n.data.type === TypeSystemDefinition.DirectiveDefinition); const directivesString = directives .map((a) => { - return `${TAB(2)}${a.name}: {\n${TAB(3)}args: ${buildArgs(a.args)}\n${TAB(2)}};`; + return `${TAB(1)}${a.name}: {\n${TAB(2)}args: ${buildArgs(a.args)}\n${TAB(1)}};`; }) .join('\n'); const typesFullString = `export type Models = {\n${typesString}\n};`; + const scalarsFullString = scalars.length + ? `export type Scalars = {\n${scalars.map((s) => `${TAB(1)}['${s.name}']: unknown;`).join('\n')}\n};` + : 'export type Scalars = unknown;'; const directivesFullString = directivesString ? `export type Directives = {\n${directivesString}\n};` - : 'export type Directives = {}'; + : 'export type Directives = unknown'; return ( - [scalarsString, enumsString, inputsString, typesFullString, directivesFullString, interfacesString, dbTypes] + [ + scalarsString, + enumsString, + inputsString, + typesFullString, + directivesFullString, + interfacesString, + scalarsFullString, + dbTypes, + ] .filter(Boolean) .join('\n\n') + '\n' ); diff --git a/packages/core/index.ts b/packages/core/index.ts index a61fb29..b5b3cb8 100644 --- a/packages/core/index.ts +++ b/packages/core/index.ts @@ -8,6 +8,7 @@ import { ObjectsUnknown, InferAdapterTypeDirectives, } from '@/types'; +import { GraphQLScalarType } from 'graphql'; export const AxolotlAdapter = () => @@ -17,7 +18,7 @@ export const AxolotlAdapter = export const Axolotl = ) => any>(adapter: ADAPTER) => // eslint-disable-next-line @typescript-eslint/ban-types - () => { + () => { type Inp = InferAdapterType; type Dir = InferAdapterTypeDirectives; type Resolvers = { @@ -25,12 +26,21 @@ export const Axolotl = [T in keyof Models[P]]?: CustomHandler; }; }; + type Scalars = { + [P in keyof ScalarModels]?: GraphQLScalarType; + }; type Directives = { [P in keyof DirectiveModels]?: Dir; }; type Handler = CustomHandler; type MiddlewareHandler = CustomMiddlewareHandler; + const createScalars = ( + k: Z & { + [P in keyof Z]: P extends keyof Scalars ? Z[P] : never; + }, + ) => k as Z; + const createResolvers = ( k: Z & { [P in keyof Z]: P extends keyof Resolvers ? Z[P] : never; @@ -69,6 +79,7 @@ export const Axolotl = return { createResolvers, createDirectives, + createScalars, applyMiddleware, adapter, }; diff --git a/packages/core/package.json b/packages/core/package.json index 3afaa9e..c16641b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@aexol/axolotl-core", - "version": "0.4.5", + "version": "0.5.0", "private": false, "main": "./lib/index.js", "author": "Aexol, Artur Czemiel", diff --git a/packages/core/types.ts b/packages/core/types.ts index 9d91710..52da834 100644 --- a/packages/core/types.ts +++ b/packages/core/types.ts @@ -1,8 +1,13 @@ +import { GraphQLScalarType } from 'graphql'; + export type ResolversUnknown = { [x: string]: { [x: string]: (input: InputType, args?: any) => any | undefined | Promise; }; }; +export type ScalarsUnknown = { + [x: string]: GraphQLScalarType; +}; export type DirectivesUnknown = { [x: string]: DirectiveType; @@ -11,6 +16,7 @@ export type DirectivesUnknown = { export type ObjectsUnknown = { resolvers: ResolversUnknown; directives?: DirectivesUnknown; + scalars?: ScalarsUnknown; }; export interface CustomHandler { diff --git a/tsconfig.json b/tsconfig.json index dc3415a..38b5151 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,9 +7,6 @@ { "path": "./packages/cli" }, - { - "path": "./adapters/stucco" - }, { "path": "./adapters/graphql-yoga" },