Skip to content

Commit

Permalink
Merge pull request #101 from nemanja-stanarevic/master
Browse files Browse the repository at this point in the history
Fix issue with buildASTSchema when both query and mutation are passed
  • Loading branch information
dschafer committed Aug 3, 2015
2 parents f9eda2e + ac7a99f commit 85d93b7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/utilities/__tests__/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import { buildASTSchema } from '../buildASTSchema';
* into an in-memory GraphQLSchema, and then finally
* printing that GraphQL into the DSL
*/
function cycleOutput(body, queryType) {
function cycleOutput(body, queryType, mutationType) {
var ast = parseSchemaIntoAST(body);
var schema = buildASTSchema(ast, queryType);
var schema = buildASTSchema(ast, queryType, mutationType);
return '\n' + printSchema(schema);
}

Expand Down Expand Up @@ -231,6 +231,22 @@ type Hello {
var output = cycleOutput(body, 'Hello');
expect(output).to.equal(body);
});

it('Simple type with mutation', () => {
var body = `
type HelloScalars {
str: String
int: Int
bool: Boolean
}
type Mutation {
addHelloScalars(str: String, int: Int, bool: Boolean): HelloScalars
}
`;
var output = cycleOutput(body, 'HelloScalars', 'Mutation');
expect(output).to.equal(body);
});
});

describe('Schema Parser Failures', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/buildASTSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function buildASTSchema(
schema = new GraphQLSchema({query: queryType});
} else {
schema = new GraphQLSchema({
query: queryTypeName,
query: queryType,
mutation: produceTypeDef(astMap[mutationTypeName]),
});
}
Expand Down

0 comments on commit 85d93b7

Please sign in to comment.