Created
July 13, 2018 22:50
-
-
Save JakeDawkins/66f5b026cf21515f1004f057754a2cd4 to your computer and use it in GitHub Desktop.
testing default enum errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
graphql, | |
GraphQLEnumType, | |
GraphQLType, | |
GraphQLSchema, | |
GraphQLObjectType, | |
GraphQLBoolean, | |
} = require('graphql'); | |
const { gql } = require('graphql-tag'); | |
const allowedColor = new GraphQLEnumType({ | |
name: 'AllowedColor', | |
values: { | |
RED: { value: '#f00' }, | |
GREEN: { value: '#0f0' }, | |
BLUE: { value: '#00f' }, | |
}, | |
}); | |
const schema = new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'Query', | |
fields: () => ({ | |
avatar: { | |
type: GraphQLBoolean, | |
args: { | |
anEnum: { | |
type: allowedColor, | |
defaultValue: 'RED', | |
}, | |
}, | |
resolve: (root, args) => (args.anEnum === 'RED' ? false : true), | |
}, | |
}), | |
}), | |
}); | |
describe('Query', () => { | |
it('queries', () => { | |
const query = gql` | |
{ | |
avatar | |
} | |
`; | |
const res = graphql(schema, query); | |
res.then(data => { | |
// this returns false right now | |
expect(data).toEqual({ data: { avatar: true } }); | |
done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment