Created
May 2, 2020 11:24
-
-
Save a7v8x/00805e7957617eb9904eefc32a48ae1d to your computer and use it in GitHub Desktop.
How to define GraphQL custom scalars - https://atheros.ai/blog/how-to-design-graphql-custom-scalars
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
import { | |
GraphQLString, | |
GraphQLID, | |
GraphQLObjectType, | |
GraphQLNonNull, | |
GraphQLInt, | |
GraphQLFloat, | |
GraphQLBoolean, | |
} from 'graphql'; | |
import DateTime from '../custom-scalars/DateTime'; | |
import TaskStateEnumType from './TaskStateEnumType'; | |
const TaskType = new GraphQLObjectType({ | |
name: 'Task', | |
fields: () => ({ | |
id: { | |
type: new GraphQLNonNull(GraphQLID), | |
}, | |
name: { | |
type: new GraphQLNonNull(GraphQLString), | |
}, | |
completed: { | |
type: new GraphQLNonNull(GraphQLBoolean), | |
defaultValue: false | |
}, | |
state: { | |
type: new GraphQLNonNull(TaskStateEnumType), | |
}, | |
progress: { | |
type: new GraphQLNonNull(GraphQLFloat), | |
}, | |
taskPriority: { | |
type: new GraphQLNonNull(GraphQLInt), | |
}, | |
dueDate: { | |
type: DateTime, | |
}, | |
createdAt: { | |
type: new GraphQLNonNull(DateTime), | |
}, | |
updatedAt: { | |
type: DateTime, | |
}, | |
}), | |
}); | |
export default TaskType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment