Skip to content

Instantly share code, notes, and snippets.

@nwillc
Last active October 13, 2016 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwillc/d5ff8b3f12ff674d1fc27897817f3a45 to your computer and use it in GitHub Desktop.
Save nwillc/d5ff8b3f12ff674d1fc27897817f3a45 to your computer and use it in GitHub Desktop.
return newObject()
.name("query")
.field(newFieldDefinition()
.name("category")
.type(category)
.argument(newArgument()
.name("key")
.type(new GraphQLNonNull(GraphQLString))
.build())
.dataFetcher(environment -> categoryDao.findOne(environment.getArgument("key")).orElse(null))
.build())
.field(newFieldDefinition()
.name("categories")
.type(new GraphQLList(category))
.dataFetcher(environment -> categoryDao.findAll().collect(Collectors.toList()))
.build())
.build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment