GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.4 KiB

  1. package graph2
  2. import (
  3. "git.aiterp.net/rpdata/api/graph2/graphcore"
  4. "git.aiterp.net/rpdata/api/graph2/resolvers"
  5. "git.aiterp.net/rpdata/api/graph2/types"
  6. "git.aiterp.net/rpdata/api/services"
  7. graphql "github.com/99designs/gqlgen/graphql"
  8. )
  9. //go:generate go run github.com/99designs/gqlgen -v
  10. // New creates a new GraphQL schema.
  11. func New(s *services.Bundle) graphql.ExecutableSchema {
  12. return graphcore.NewExecutableSchema(graphcore.Config{
  13. Resolvers: &rootResolver{s},
  14. Complexity: complexity(),
  15. })
  16. }
  17. type rootResolver struct {
  18. s *services.Bundle
  19. }
  20. func (r *rootResolver) Query() graphcore.QueryResolver {
  21. return resolvers.QueryResolver(r.s)
  22. }
  23. func (r *rootResolver) Mutation() graphcore.MutationResolver {
  24. return resolvers.MutationResolver(r.s)
  25. }
  26. func (r *rootResolver) Subscription() graphcore.SubscriptionResolver {
  27. return resolvers.SubscriptionResolver(r.s)
  28. }
  29. func (r *rootResolver) Log() graphcore.LogResolver {
  30. return types.LogResolver(r.s)
  31. }
  32. func (r *rootResolver) Comment() graphcore.CommentResolver {
  33. return types.CommentResolver(r.s)
  34. }
  35. func (r *rootResolver) Chapter() graphcore.ChapterResolver {
  36. return types.ChapterResolver(r.s)
  37. }
  38. func (r *rootResolver) Story() graphcore.StoryResolver {
  39. return types.StoryResolver(r.s)
  40. }
  41. func (r *rootResolver) Change() graphcore.ChangeResolver {
  42. return &types.ChangeResolver
  43. }
  44. func (r *rootResolver) Token() graphcore.TokenResolver {
  45. return types.TokenResolver(r.s)
  46. }