Skip to content

Commit 85d93b7

Browse files
committed
Merge pull request #101 from nemanja-stanarevic/master
Fix issue with buildASTSchema when both query and mutation are passed
2 parents f9eda2e + ac7a99f commit 85d93b7

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/utilities/__tests__/buildASTSchema.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ import { buildASTSchema } from '../buildASTSchema';
2020
* into an in-memory GraphQLSchema, and then finally
2121
* printing that GraphQL into the DSL
2222
*/
23-
function cycleOutput(body, queryType) {
23+
function cycleOutput(body, queryType, mutationType) {
2424
var ast = parseSchemaIntoAST(body);
25-
var schema = buildASTSchema(ast, queryType);
25+
var schema = buildASTSchema(ast, queryType, mutationType);
2626
return '\n' + printSchema(schema);
2727
}
2828

@@ -231,6 +231,22 @@ type Hello {
231231
var output = cycleOutput(body, 'Hello');
232232
expect(output).to.equal(body);
233233
});
234+
235+
it('Simple type with mutation', () => {
236+
var body = `
237+
type HelloScalars {
238+
str: String
239+
int: Int
240+
bool: Boolean
241+
}
242+
243+
type Mutation {
244+
addHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars
245+
}
246+
`;
247+
var output = cycleOutput(body, 'HelloScalars', 'Mutation');
248+
expect(output).to.equal(body);
249+
});
234250
});
235251

236252
describe('Schema Parser Failures', () => {

src/utilities/buildASTSchema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export function buildASTSchema(
151151
schema = new GraphQLSchema({query: queryType});
152152
} else {
153153
schema = new GraphQLSchema({
154-
query: queryTypeName,
154+
query: queryType,
155155
mutation: produceTypeDef(astMap[mutationTypeName]),
156156
});
157157
}

0 commit comments

Comments
 (0)