Skip to content

Commit f871525

Browse files
committed
fix(codegen): Adjust generated code
1 parent 742d003 commit f871525

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/codegen/index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as path from 'path'
2-
import {PluginFunction} from '@graphql-codegen/plugin-helpers';
2+
import {PluginFunction, PluginValidateFn} from '@graphql-codegen/plugin-helpers';
33
import {OperationDefinitionNode} from "graphql"
4-
import defineProperty = Reflect.defineProperty
54

65
export const plugin: PluginFunction = async (schema, documents, config, info) => {
76
const mappedDocuments: {[key: string]: OperationDefinitionNode[]} = documents.reduce((previous, document) => {
@@ -51,17 +50,14 @@ export const plugin: PluginFunction = async (schema, documents, config, info) =>
5150

5251
const typeDefinition = `declare module 'vue/types/vue' {
5352
interface Vue {
54-
$gql(): {
55-
operations: typeof GraphQLInjectDefinition
56-
}
53+
$gql: typeof GraphQLInjectDefinition
5754
}
5855
}`
5956

6057
return imports + '\n' + injectDefinition + '\n' + typeDefinition
6158
}
6259

63-
/*export const validate: PluginValidateFn<any> = async (schema: GraphQLSchema, documents: Types.DocumentFile[], config: any, outputFile: string) => {
64-
if (!outputFile.endsWith('.d.ts')) {
65-
throw new Error(`Plugin "typescript-graphql-files-modules" requires extension to be ".d.ts"!`);
66-
}
67-
};*/
60+
export const validate: PluginValidateFn<any> = (schema, documents, config, outputFile) => {
61+
if (!outputFile.endsWith('.ts') || outputFile.endsWith('.d.ts'))
62+
throw Error(`Plugin "vue-graphql-inject/lib/codegen" requires extension to be ".ts"!`)
63+
}

0 commit comments

Comments
 (0)