@aexol/axolotl-graphql-yoga 0.0.1

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/.eslintrc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "../../.eslintrc.json"
4
+ ]
5
+ }
package/index.ts ADDED
@@ -0,0 +1,35 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { readFileSync } from 'fs';
3
+ import { AxolotlAdapter } from '@aexol/axolotl-core';
4
+ import { YogaInitialContext, createSchema, createYoga } from 'graphql-yoga';
5
+ import { createServer } from 'http';
6
+ import * as path from 'path';
7
+
8
+ export const graphqlYogaAdapter = AxolotlAdapter<[any, any, YogaInitialContext]>()((resolvers) => {
9
+ const yogaResolvers = Object.fromEntries(
10
+ Object.entries(resolvers).map(([typeName, v]) => {
11
+ return [
12
+ typeName,
13
+ Object.fromEntries(
14
+ Object.entries(v).map(([fieldName, resolver]) => {
15
+ return [
16
+ fieldName,
17
+ (_: any, args: any, context: YogaInitialContext) => {
18
+ return resolver([_, args, context], args);
19
+ },
20
+ ];
21
+ }),
22
+ ),
23
+ ];
24
+ }),
25
+ );
26
+ const schemaFile = readFileSync(path.join(process.cwd(), './schema.graphql'), 'utf-8');
27
+ const yoga = createYoga({
28
+ schema: createSchema({
29
+ typeDefs: schemaFile,
30
+ resolvers: yogaResolvers,
31
+ }),
32
+ });
33
+ const server = createServer(yoga);
34
+ return server;
35
+ });
package/jest.config.js ADDED
@@ -0,0 +1,10 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ moduleFileExtensions: ['ts', 'tsx', 'js'],
4
+ moduleNameMapper: {
5
+ '@/(.*)': ['<rootDir>/$1'],
6
+ },
7
+ testMatch: ['<rootDir>/**/*.spec.(ts|tsx)'],
8
+ watchPathIgnorePatterns: ['node_modules'],
9
+ watchman: false,
10
+ };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@aexol/axolotl-graphql-yoga",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "main": "./lib/index.js",
6
+ "author": "Aexol, Artur Czemiel",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "tspc",
10
+ "start": "tspc --watch",
11
+ "lint": "tspc && eslint \"./src/**/*.{ts,js}\" --quiet --fix"
12
+ },
13
+ "dependencies": {
14
+ "graphql": "^16.8.1",
15
+ "graphql-yoga": "^4.0.5",
16
+ "stucco-js": "^0.10.18"
17
+ }
18
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "compilerOptions": {
3
+ "sourceMap": true,
4
+ "target": "es2022",
5
+ "module": "es2022",
6
+ "moduleResolution": "node",
7
+ "experimentalDecorators": true,
8
+ "declaration": true,
9
+ "incremental": true,
10
+ "removeComments": true,
11
+ "noUnusedLocals": true,
12
+ "strictNullChecks": true,
13
+ "skipLibCheck": true,
14
+ "strict": true,
15
+ "outDir": "./lib",
16
+ "lib": [
17
+ "ESNext",
18
+ "DOM",
19
+ "DOM.Iterable"
20
+ ],
21
+ "rootDir": "./",
22
+ "baseUrl": "./",
23
+ "composite": true,
24
+ "paths": {
25
+ "@/*": [
26
+ "./*"
27
+ ]
28
+ },
29
+ "plugins": [
30
+ {
31
+ "transform": "typescript-transform-paths"
32
+ },
33
+ {
34
+ "transform": "typescript-transform-paths",
35
+ "afterDeclarations": true
36
+ }
37
+ ]
38
+ },
39
+ "exclude": [
40
+ "lib",
41
+ "node_modules",
42
+ "jest.config.js"
43
+ ]
44
+ }