-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): New GraphQL Code Generator (#413)
- Loading branch information
1 parent
533707e
commit 6677531
Showing
23 changed files
with
1,613 additions
and
1,097 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}), | ||
{} | ||
) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// ==================================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.