Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/__tests__/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/resources/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/'),
),
),
);
Expand Down