Guest User

Untitled

a guest
Jan 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. export const SingerType = new GraphQLObjectType({
  2. name: "Singer",
  3. description: "A band´s singer",
  4. fields: () => ({
  5. id: {
  6. type: new GraphQLNonNull(GraphQLID),
  7. },
  8. name: {
  9. type: new GraphQLNonNull(GraphQLString)
  10. },
  11. band: {
  12. type: new GraphQLNonNull(BandType),
  13. resolve: (source, args, context) => {
  14. return Band.findOne({
  15. _id: source.band_id
  16. }).exec();
  17. }
  18. }
  19. albuns: {
  20. type: new GraphQLList(AlbumType),
  21. resolve: (source, args, context) => {
  22. return Album.find({
  23. _id: source._id
  24. }).exec();
  25. }
  26. }
  27. })
  28. });
  29.  
  30. export const SingerInputType = new GraphQLInputObjectType({
  31. name: "SingerInput",
  32. description: "Band´s singer input type",
  33. fields: () => ({
  34. name: {
  35. type: new GraphQLNonNull(GraphQLString)
  36. },
  37. band_id: {
  38. type: new GraphQLNonNull(GraphQLString) <<== GraphQLString or GraphQLID here ???
  39. },
  40. albuns: {
  41. type: new GraphQLList(GraphQLString) <<== GraphQLString or GraphQLID here ???
  42. } }
  43. })
  44. });
Add Comment
Please, Sign In to add comment