diff --git a/examples/1-simple-model/generated/index.ts b/examples/1-simple-model/generated/index.ts index d7d17c69..f37d9645 100644 --- a/examples/1-simple-model/generated/index.ts +++ b/examples/1-simple-model/generated/index.ts @@ -1 +1 @@ -export * from './classes'; +export * from './classes'; \ No newline at end of file diff --git a/examples/1-simple-model/generated/schema.ts b/examples/1-simple-model/generated/schema.ts deleted file mode 100644 index a7605d16..00000000 --- a/examples/1-simple-model/generated/schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as fs from 'fs'; -import { makeExecutableSchema } from 'graphql-tools'; -import { GraphQLSchema } from 'graphql'; - -const schema: GraphQLSchema = makeExecutableSchema({ - typeDefs: fs.readFileSync(__dirname + '/schema.graphql', 'utf-8'), - resolverValidationOptions: { - requireResolversForResolveType: false - } -}); - -export default schema; diff --git a/examples/2-complex-example/generated/index.ts b/examples/2-complex-example/generated/index.ts deleted file mode 100644 index d7d17c69..00000000 --- a/examples/2-complex-example/generated/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './classes'; diff --git a/examples/2-complex-example/generated/schema.ts b/examples/2-complex-example/generated/schema.ts deleted file mode 100644 index a7605d16..00000000 --- a/examples/2-complex-example/generated/schema.ts +++ /dev/null @@ -1,12 +0,0 @@ -import * as fs from 'fs'; -import { makeExecutableSchema } from 'graphql-tools'; -import { GraphQLSchema } from 'graphql'; - -const schema: GraphQLSchema = makeExecutableSchema({ - typeDefs: fs.readFileSync(__dirname + '/schema.graphql', 'utf-8'), - resolverValidationOptions: { - requireResolversForResolveType: false - } -}); - -export default schema; diff --git a/src/core/app.ts b/src/core/app.ts index ff397abe..f29335c9 100644 --- a/src/core/app.ts +++ b/src/core/app.ts @@ -104,11 +104,21 @@ export class App { }); } + async writeGeneratedIndexFile() { + // Write schema to dist folder so that it's available in package + const contents = `export * from './classes';`; + return writeFileSync(path.join(this.generatedFolder, 'index.ts'), contents, { + encoding: 'utf8', + flag: 'w' + }); + } + async start() { await this.establishDBConnection(); await this.generateTypes(); await this.buildGraphQLSchema(); await this.writeSchemaFile(); + await this.writeGeneratedIndexFile(); await this.generateBinding(); this.graphQLServer = new ApolloServer({