Advertisement
Guest User

Untitled

a guest
May 19th, 2020
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const AlbumType = new GraphQLObjectType({
  2.   name: "Album",
  3.   fields: {
  4.     id: {
  5.       type: new GraphQLNonNull(GraphQLInt),
  6.       description: "The id of the Album."
  7.     },
  8.     name: {
  9.       type: new GraphQLNonNull(GraphQLString),
  10.       description: "The name of the Album."
  11.     },
  12.     year: {
  13.       type: GraphQLString,
  14.       description: "The year of the Album."
  15.     },
  16.     artist_id: {
  17.       type: GraphQLInt,
  18.       description: "The artist_id of the Album."
  19.     },
  20.     artist: {
  21.       type: ArtistType,
  22.       resolve: (parent) => parent.getArtist()
  23.     }
  24.   }
  25. })
  26.  
  27. const ArtistType = new GraphQLObjectType({
  28.   name: "Artist",
  29.   fields: {
  30.     id: {
  31.       type: new GraphQLNonNull(GraphQLInt),
  32.       description: "The id of the Artist."
  33.     },
  34.     name: {
  35.       type: new GraphQLNonNull(GraphQLString),
  36.       description: "The name of the Artist."
  37.     },
  38.     url: {
  39.       type: GraphQLString,
  40.       description: "The url of the Artist."
  41.     },
  42.     albums: {
  43.       type: new GraphQLList(AlbumType),
  44.       resolve: (parent, args, context) => parent.getAlbums()
  45.     }
  46.   }
  47. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement