Skip to content

Commit

Permalink
Introduce JSON Schema validations and auto-complete for codegen.yml (
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha authored May 25, 2020
1 parent 10db585 commit 80a1e67
Show file tree
Hide file tree
Showing 139 changed files with 10,900 additions and 2,416 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ junit.xml
dist
.bob
out.txt
.cache
tsconfig.tsbuildinfo
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"./website/static/config.schema.json": "*codegen.*"
}
}
2 changes: 1 addition & 1 deletion bob.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
ignore: ['@graphql-codegen/website', '@graphql-codegen/live-demo'],
ignore: ['@graphql-codegen/website', '@graphql-codegen/live-demo', '@graphql-codegen/config-schema'],
};
1 change: 0 additions & 1 deletion dev-test/codegen.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
overwrite: true
hooks:
afterAllFileWrite:
- prettier --write
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@types/request": "2.48.5",
"@vue/apollo-composable": "4.0.0-alpha.8",
"@vue/composition-api": "0.5.0",
"bob-the-bundler": "1.0.1",
"bob-the-bundler": "1.0.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"apollo-cache": "1.3.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function executeCodegen(input: CodegenContext | Types.Config): Prom
await import(mod);
}

/* Root templates-config */
/* Root plugin config */
rootConfig = config.config || {};

/* Normalize root "schema" field */
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export async function createContext(
}

export function updateContextWithCliFlags(context: CodegenContext, cliFlags: Command & YamlCliFlags) {
const config: Partial<Types.Config> = {
const config: Partial<Types.Config & { configFilePath?: string }> = {
configFilePath: context.filepath,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/src/generate-and-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { createHash } from 'crypto';
const hash = (content: string): string => createHash('sha1').update(content).digest('base64');

export async function generate(
input: CodegenContext | Types.Config,
input: CodegenContext | (Types.Config & { cwd?: string }),
saveToFile = true
): Promise<Types.FileOutput[] | any> {
const context = ensureContext(input);
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql-codegen-cli/src/utils/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const createWatcher = (
onNext: (result: Types.FileOutput[]) => Promise<Types.FileOutput[]>
) => {
debugLog(`[Watcher] Starting watcher...`);
let config: Types.Config = initalContext.getConfig();
let config: Types.Config & { configFilePath?: string } = initalContext.getConfig();
const files: string[] = [initalContext.filepath].filter(a => a);
const documents = normalizeInstanceOrArray<Types.OperationDocument>(config.documents);
const schemas = normalizeInstanceOrArray<Types.Schema>(config.schema);
Expand Down Expand Up @@ -125,7 +125,7 @@ export const createWatcher = (
log(`${logSymbols.info} Config file has changed, reloading...`);
const context = await loadContext(config.configFilePath);

const newParsedConfig = context.getConfig();
const newParsedConfig: Types.Config & { configFilePath?: string } = context.getConfig();
newParsedConfig.watch = config.watch;
newParsedConfig.silent = config.silent;
newParsedConfig.overwrite = config.overwrite;
Expand Down
Loading

0 comments on commit 80a1e67

Please sign in to comment.