Skip to content

Commit e404bd4

Browse files
committed
new version with deno support
1 parent 8a8f3e5 commit e404bd4

File tree

10 files changed

+22
-17
lines changed

10 files changed

+22
-17
lines changed

examples/typescript-node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typescript-node",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "",
55
"private": true,
66
"main": "index.js",

examples/typescript-node/src/zeus/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* eslint-disable */
22

33
import { AllTypesProps, ReturnTypes, Ops } from './const.js';
4-
import fetch, { Response } from 'node-fetch';
5-
import WebSocket from 'ws';
64
export const HOST = "https://faker.prod.graphqleditor.com/a-team/olympus/graphql"
75

86

packages/graphql-zeus-core/TranslateGraphQL/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface TranslateOptions {
77
env?: Environment;
88
host?: string;
99
esModule?: boolean;
10+
deno?: boolean;
1011
subscriptions?: 'legacy' | 'graphql-ws';
1112
constEnums?: boolean;
1213
}
@@ -23,11 +24,12 @@ export class TranslateGraphQL {
2324
env = 'browser',
2425
host,
2526
esModule,
27+
deno,
2628
subscriptions = 'legacy',
2729
constEnums,
2830
}: TranslateOptions) => {
2931
const tree = Parser.parseAddExtensions(schema);
30-
const ts = TreeToTS.resolveTreeSplit({ tree, env, host, esModule, subscriptions, constEnums });
32+
const ts = TreeToTS.resolveTreeSplit({ tree, env, host, esModule, subscriptions, constEnums, deno });
3133
return {
3234
const: TreeToTS.resolveBasisHeader().concat(ts.const),
3335
index: TreeToTS.resolveBasisHeader().concat(ts.indexImports).concat('\n').concat(ts.index),

packages/graphql-zeus-core/TreeToTS/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface ResolveOptions {
3535
host?: string;
3636
headers?: Record<string, string>;
3737
esModule?: boolean;
38+
deno?: boolean;
3839
subscriptions?: 'legacy' | 'graphql-ws';
3940
constEnums?: boolean;
4041
}
@@ -108,17 +109,12 @@ export class TreeToTS {
108109
headers,
109110
subscriptions = 'legacy',
110111
constEnums,
112+
deno,
111113
}: ResolveOptions) {
112114
return {
113115
indexImports: `import { AllTypesProps, ReturnTypes, Ops } from './const${
114-
esModule || env === 'node' ? '.js' : ''
115-
}';`.concat(
116-
env === 'node'
117-
? `
118-
import fetch, { Response } from 'node-fetch';
119-
import WebSocket from 'ws';`
120-
: ``,
121-
),
116+
deno ? '.ts' : esModule || env === 'node' ? '.js' : ''
117+
}';`,
122118
const: TreeToTS.resolveBasisCode(tree),
123119
index: ''
124120
.concat(host ? `export const HOST = "${host}"` : '\n\nexport const HOST="Specify host"')

packages/graphql-zeus-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus-core",
3-
"version": "7.1.1",
3+
"version": "7.1.2",
44
"private": false,
55
"main": "./lib/index.js",
66
"author": "GraphQL Editor, Artur Czemiel",

packages/graphql-zeus-jsonschema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus-jsonschema",
3-
"version": "7.1.1",
3+
"version": "7.1.2",
44
"private": false,
55
"main": "./lib/index.js",
66
"author": "GraphQL Editor, Artur Czemiel",

packages/graphql-zeus/CLIClass.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface Yargs {
2121
interface CliArgs extends Yargs {
2222
header?: string;
2323
esModule?: boolean;
24+
deno?: boolean;
2425
node?: boolean;
2526
graphql?: string;
2627
jsonSchema?: string;
@@ -81,6 +82,7 @@ export class CLI {
8182
schema: schemaFileContents,
8283
env,
8384
host,
85+
deno: !!args.deno,
8486
esModule: !!args.esModule,
8587
constEnums: !!args.constEnums,
8688
subscriptions: args.subscriptions === 'graphql-ws' ? 'graphql-ws' : 'legacy',

packages/graphql-zeus/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ConfigMaker } from 'config-maker';
33
export type ProjectOptions = {
44
urlOrPath: string;
55
esModule?: boolean;
6+
deno?: boolean;
67
headers?: {
78
[x: string]: string;
89
};
@@ -19,6 +20,7 @@ export const config = new ConfigMaker<ProjectOptions>('graphql-zeus', {
1920
decoders: {},
2021
defaultValues: {
2122
esModule: false,
23+
deno: false,
2224
method: 'POST',
2325
headers: {},
2426
node: false,

packages/graphql-zeus/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ zeus [path] [output_path] [options]
2121
describe: 'Use .js import in TypeScript to use with esModules',
2222
boolean: true,
2323
})
24+
.option('deno', {
25+
alias: 'de',
26+
describe: 'Use .ts import in TypeScript to use with deno',
27+
boolean: true,
28+
})
2429
.option('constEnums', {
2530
alias: 'ce',
2631
describe: 'Use .js import in TypeScript to use with esModules',

packages/graphql-zeus/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-zeus",
3-
"version": "7.1.1",
3+
"version": "7.1.2",
44
"private": false,
55
"scripts": {
66
"start": "ttsc --watch",
@@ -26,8 +26,8 @@
2626
"dependencies": {
2727
"config-maker": "^0.0.6",
2828
"cross-fetch": "^3.0.4",
29-
"graphql-zeus-core": "^7.1.1",
30-
"graphql-zeus-jsonschema": "^7.1.1",
29+
"graphql-zeus-core": "^7.1.2",
30+
"graphql-zeus-jsonschema": "^7.1.2",
3131
"yargs": "^16.1.1"
3232
}
3333
}

0 commit comments

Comments
 (0)