Skip to content

Commit

Permalink
feat(build): New GraphQL Code Generator (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and mrmeku committed Nov 29, 2018
1 parent 533707e commit 6677531
Show file tree
Hide file tree
Showing 23 changed files with 1,613 additions and 1,097 deletions.
40 changes: 40 additions & 0 deletions codegen-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { resolve, join, relative } = require('path');
const { lstatSync, readdirSync } = require('fs');

function listLibs() {
const libs = resolve(__dirname, 'libs');
const isDirectory = source => lstatSync(source).isDirectory();

return readdirSync(libs)
.map(name => join(libs, name))
.filter(isDirectory)
.map(source => relative(libs, source));
}

function generateLib(lib) {
return {
output: resolve(__dirname, `libs/${lib}/src/lib/generated/graphql.ts`),
config: {
documents: `./libs/${lib}/src/lib/graphql/**/*.graphql`,
plugins: [
'typescript-common',
'typescript-client',
'typescript-apollo-angular'
]
}
};
}

module.exports = {
schema: resolve(__dirname, 'server/src/schema/schema.graphql'),
overwrite: true,
generates: listLibs()
.map(generateLib)
.reduce(
(generates, lib) => ({
...generates,
[lib.output]: lib.config
}),
{}
)
};
13 changes: 13 additions & 0 deletions codegen-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
overwrite: true
schema: ./server/src/schema/schema.graphql
generates:
./server/src/graphql-types.ts:
config:
# a type of GraphQL Context
contextType: 'any'
# a type of every resolver's parent
defaultMapper: 'any'
plugins:
- typescript-common
- typescript-server
- typescript-resolvers
20 changes: 3 additions & 17 deletions libs/feature-action-bar/src/lib/generated/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
/* tslint:disable */

// ====================================================
// START: Typescript template
// ====================================================

// ====================================================
// Enums
// ====================================================

export enum FileType {
file = 'file',
directory = 'directory',
angularDirectory = 'angularDirectory'
File = 'file',
Directory = 'directory',
AngularDirectory = 'angularDirectory'
}

// ====================================================
// END: Typescript template
// ====================================================
37 changes: 11 additions & 26 deletions libs/feature-extensions/src/lib/generated/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
/* tslint:disable */

// ====================================================
// START: Typescript template
// ====================================================

// ====================================================
// Enums
// ====================================================

export enum FileType {
file = 'file',
directory = 'directory',
angularDirectory = 'angularDirectory'
File = 'file',
Directory = 'directory',
AngularDirectory = 'angularDirectory'
}

// ====================================================
// END: Typescript template
// ====================================================

// ====================================================
// Documents
// ====================================================
Expand All @@ -31,7 +17,7 @@ export namespace NgAdd {
export type Mutation = {
__typename?: 'Mutation';

ngAdd?: NgAdd | null;
ngAdd: NgAdd | null;
};

export type NgAdd = {
Expand All @@ -52,13 +38,13 @@ export namespace WorkspaceAndExtensionsByName {

workspace: Workspace;

availableExtensions?: (AvailableExtensions | null)[] | null;
availableExtensions: (AvailableExtensions | null)[] | null;
};

export type Workspace = {
__typename?: 'Workspace';

extensions?: (Extensions | null)[] | null;
extensions: (Extensions | null)[] | null;
};

export type Extensions = {
Expand All @@ -72,9 +58,9 @@ export namespace WorkspaceAndExtensionsByName {

name: string;

description?: string | null;
description: string | null;

detailedDescription?: string | null;
detailedDescription: string | null;
};
}

Expand All @@ -88,13 +74,13 @@ export namespace WorkspaceAndExtensions {

workspace: Workspace;

availableExtensions?: (AvailableExtensions | null)[] | null;
availableExtensions: (AvailableExtensions | null)[] | null;
};

export type Workspace = {
__typename?: 'Workspace';

extensions?: (Extensions | null)[] | null;
extensions: (Extensions | null)[] | null;
};

export type Extensions = {
Expand All @@ -108,7 +94,7 @@ export namespace WorkspaceAndExtensions {

name: string;

description?: string | null;
description: string | null;
};
}

Expand All @@ -117,7 +103,6 @@ export namespace WorkspaceAndExtensions {
// ====================================================

import { Injectable } from '@angular/core';

import * as Apollo from 'apollo-angular';

import gql from 'graphql-tag';
Expand Down
47 changes: 16 additions & 31 deletions libs/feature-generate/src/lib/generated/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
/* tslint:disable */

// ====================================================
// START: Typescript template
// ====================================================

// ====================================================
// Enums
// ====================================================

export enum FileType {
file = 'file',
directory = 'directory',
angularDirectory = 'angularDirectory'
File = 'file',
Directory = 'directory',
AngularDirectory = 'angularDirectory'
}

// ====================================================
// END: Typescript template
// ====================================================

// ====================================================
// Documents
// ====================================================
Expand All @@ -32,7 +18,7 @@ export namespace Generate {
export type Mutation = {
__typename?: 'Mutation';

generate?: Generate | null;
generate: Generate | null;
};

export type Generate = {
Expand All @@ -58,13 +44,13 @@ export namespace SchematicCollectionsByName {
export type Workspace = {
__typename?: 'Workspace';

schematicCollections?: (SchematicCollections | null)[] | null;
schematicCollections: (SchematicCollections | null)[] | null;
};

export type SchematicCollections = {
__typename?: 'SchematicCollection';

schematics?: (Schematics | null)[] | null;
schematics: (Schematics | null)[] | null;
};

export type Schematics = {
Expand All @@ -74,23 +60,23 @@ export namespace SchematicCollectionsByName {

name: string;

description?: string | null;
description: string | null;

schema?: (Schema | null)[] | null;
schema: (Schema | null)[] | null;
};

export type Schema = {
__typename?: 'SchematicSchema';

name: string;

enum?: (string | null)[] | null;
enum: (string | null)[] | null;

type: string;

description?: string | null;
description: string | null;

defaultValue?: string | null;
defaultValue: string | null;

required: boolean;

Expand Down Expand Up @@ -128,9 +114,9 @@ export namespace SchematicDocs {

id: string;

description?: string | null;
description: string | null;

prop?: string | null;
prop: string | null;
};
}

Expand All @@ -148,23 +134,23 @@ export namespace SchematicCollections {
export type Workspace = {
__typename?: 'Workspace';

schematicCollections?: (SchematicCollections | null)[] | null;
schematicCollections: (SchematicCollections | null)[] | null;
};

export type SchematicCollections = {
__typename?: 'SchematicCollection';

name: string;

schematics?: (Schematics | null)[] | null;
schematics: (Schematics | null)[] | null;
};

export type Schematics = {
__typename?: 'Schematic';

name: string;

description?: string | null;
description: string | null;

collection: string;
};
Expand All @@ -175,7 +161,6 @@ export namespace SchematicCollections {
// ====================================================

import { Injectable } from '@angular/core';

import * as Apollo from 'apollo-angular';

import gql from 'graphql-tag';
Expand Down
39 changes: 12 additions & 27 deletions libs/feature-install-node-js/src/lib/generated/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
/* tslint:disable */

// ====================================================
// START: Typescript template
// ====================================================

// ====================================================
// Enums
// ====================================================

export enum FileType {
file = 'file',
directory = 'directory',
angularDirectory = 'angularDirectory'
File = 'file',
Directory = 'directory',
AngularDirectory = 'angularDirectory'
}

// ====================================================
// END: Typescript template
// ====================================================

// ====================================================
// Documents
// ====================================================
Expand All @@ -28,21 +14,21 @@ export namespace InstallNodeJsStatus {
export type Query = {
__typename?: 'Query';

installNodeJsStatus?: InstallNodeJsStatus | null;
installNodeJsStatus: InstallNodeJsStatus | null;
};

export type InstallNodeJsStatus = {
__typename?: 'InstallNodeJsStatus';

downloadPercentage?: number | null;
downloadPercentage: number | null;

downloadSpeed?: number | null;
downloadSpeed: number | null;

success?: boolean | null;
success: boolean | null;

cancelled?: boolean | null;
cancelled: boolean | null;

error?: string | null;
error: string | null;
};
}

Expand All @@ -52,13 +38,13 @@ export namespace InstallNodeJs {
export type Mutation = {
__typename?: 'Mutation';

installNodeJs?: InstallNodeJs | null;
installNodeJs: InstallNodeJs | null;
};

export type InstallNodeJs = {
__typename?: 'InstallNodeJsStatus';

cancelled?: boolean | null;
cancelled: boolean | null;
};
}

Expand All @@ -68,7 +54,7 @@ export namespace IsNodejsInstalled {
export type Query = {
__typename?: 'Query';

isNodejsInstalled?: IsNodejsInstalled | null;
isNodejsInstalled: IsNodejsInstalled | null;
};

export type IsNodejsInstalled = {
Expand All @@ -83,7 +69,6 @@ export namespace IsNodejsInstalled {
// ====================================================

import { Injectable } from '@angular/core';

import * as Apollo from 'apollo-angular';

import gql from 'graphql-tag';
Expand Down
Loading

0 comments on commit 6677531

Please sign in to comment.