diff --git a/src/__tests__/schema.test.ts b/src/__tests__/schema.test.ts index deae80fe..df15b8ec 100644 --- a/src/__tests__/schema.test.ts +++ b/src/__tests__/schema.test.ts @@ -137,6 +137,48 @@ describe('schema', () => { `); }); + it('should merge glob schemas with Windows paths', () => { + const api = new Api(given.appSyncConfig(), plugin); + const schema = new Schema(api, [ + 'src\\__tests__\\fixtures\\schemas\\multiple\\*.graphql', + ]); + expect(schema.generateSchema()).toMatchInlineSnapshot(` + "type Mutation { + createPost(post: PostInput!): Post! + createUser(post: UserInput!): User! + } + + type Post @aws_oidc { + id: ID! + title: String! + createdAt: AWSDateTime! + updatedAt: AWSDateTime! + } + + \\"\\"\\"This is a description\\"\\"\\" + input PostInput { + title: String! + } + + type Query { + getPost(id: ID!): Post! + getUser: User! + } + + type User { + id: ID! + name: String! + role: String! @aws_oidc + email: AWSEmail! + posts: [Post!]! + } + + input UserInput { + name: String! + }" + `); + }); + it('should fail if schema is invalid', () => { const api = new Api( given.appSyncConfig({ diff --git a/src/resources/Schema.ts b/src/resources/Schema.ts index e4a24ebe..86aa4e04 100644 --- a/src/resources/Schema.ts +++ b/src/resources/Schema.ts @@ -63,7 +63,9 @@ export class Schema { const schemaFiles = flatten( globby.sync( this.schemas.map((schema) => - path.join(this.api.plugin.serverless.config.servicePath, schema), + path + .join(this.api.plugin.serverless.config.servicePath, schema) + .replace(/\\/g, '/'), ), ), );