GraphQL Assignment-2

Basic Questions

  1. Define a schema with Movie { id, title, rating }.
  2. Write query getMovies that returns all movies.
  3. Implement resolver for getMovie(id:ID!): Movie.
  4. Create mutation addMovie(title:String!,rating:Int!): Movie.
  5. Define input MovieInput { title:String!, rating:Int! } and use it in mutation.
  6. Implement resolver for addMovie(input:MovieInput!): Movie.
  7. Create an enum Genre { ACTION, DRAMA, COMEDY }.
  8. Extend Movie type with genre: Genre.
  9. Write mutation updateGenre(id:ID!,genre:Genre!): Movie.
  10. Implement resolver to update movie genre.
  11. Define custom scalar Date for releaseDate.
  12. Use Date scalar in Movie type and fetch formatted dates.
  13. Create a schema type Actor { id, name, age }.
  14. Write query to fetch all actors.
  15. Implement resolver getActor(id:ID!): Actor.
  16. Write mutation addActor(name:String!,age:Int!): Actor.
  17. Define a query with variables to fetch movie by title.
  18. Use alias to fetch movie title twice under different names.
  19. Write query with fragment for common fields id, title.
  20. Test query with variables in GraphQL Playground.

 Intermediate Questions

  1. Extend schema: Actor { movies: [Movie] }.
  2. Implement resolver to return movies for an actor.
  3. Create nested query: fetch actor and their movies.
  4. Add mutation assignActorToMovie(actorId:ID!,movieId:ID!): Movie.
  5. Implement resolver for assignActorToMovie.
  6. Create Director { id, name, age }.
  7. Extend Movie type with director: Director.
  8. Write nested query to fetch movie with director info.
  9. Define interface Person { id, name }.
  10. Implement Actor and Director as implements Person.
  11. Write query returning a list of Person (actors + directors).
  12. Define union SearchResult = Movie | Actor.
  13. Write query search(keyword:String!): [SearchResult].
  14. Implement resolver for union type SearchResult.
  15. Use directive @deprecated on a field oldRating.
  16. Test query using deprecated field.
  17. Implement @include(if:Boolean) directive in query.
  18. Implement @skip(if:Boolean) directive in query.
  19. Create mutation updateActorAge(id:ID!,age:Int!): Actor.
  20. Test mutation with variables in Playground.

 Advanced Questions  

  1. Design schema where User has relationships with Posts and Comments.
  2. Write nested query: user → posts → comments.
  3. Implement resolver with multiple nested resolvers.
  4. Add directive @auth (custom) on query getUsers.
  5. Implement resolver to check authentication before returning data.
  6. Use fragments to fetch nested fields for both Actor and Director.
  7. Implement query that fetches multiple types with fragments.
  8. Create mutation with input type RegisterUserInput.
  9. Add resolver for registerUser mutation with validation.
  10. Implement advanced query with variables + fragments + alias combined.