Browse Source

Renamed queries package to resolvers.

thegreatrefactor
Gisle Aune 6 years ago
parent
commit
53c3d4597b
  1. 8
      graph2/graph.go
  2. 4
      graph2/resolvers/changes.go
  3. 6
      graph2/resolvers/channel.go
  4. 4
      graph2/resolvers/chapter.go
  5. 6
      graph2/resolvers/character.go
  6. 4
      graph2/resolvers/comment.go
  7. 6
      graph2/resolvers/file.go
  8. 6
      graph2/resolvers/log.go
  9. 6
      graph2/resolvers/post.go
  10. 6
      graph2/resolvers/resolvers.go
  11. 6
      graph2/resolvers/story.go
  12. 4
      graph2/resolvers/tags.go
  13. 4
      graph2/resolvers/token.go
  14. 4
      graph2/resolvers/unknownnicks.go

8
graph2/graph.go

@ -2,7 +2,7 @@ package graph2
import ( import (
"git.aiterp.net/rpdata/api/graph2/graphcore" "git.aiterp.net/rpdata/api/graph2/graphcore"
"git.aiterp.net/rpdata/api/graph2/queries"
"git.aiterp.net/rpdata/api/graph2/resolvers"
"git.aiterp.net/rpdata/api/graph2/types" "git.aiterp.net/rpdata/api/graph2/types"
"git.aiterp.net/rpdata/api/services" "git.aiterp.net/rpdata/api/services"
graphql "github.com/99designs/gqlgen/graphql" graphql "github.com/99designs/gqlgen/graphql"
@ -23,15 +23,15 @@ type rootResolver struct {
} }
func (r *rootResolver) Query() graphcore.QueryResolver { func (r *rootResolver) Query() graphcore.QueryResolver {
return queries.QueryResolver(r.s)
return resolvers.QueryResolver(r.s)
} }
func (r *rootResolver) Mutation() graphcore.MutationResolver { func (r *rootResolver) Mutation() graphcore.MutationResolver {
return queries.MutationResolver
return resolvers.MutationResolver
} }
func (r *rootResolver) Subscription() graphcore.SubscriptionResolver { func (r *rootResolver) Subscription() graphcore.SubscriptionResolver {
return queries.SubscriptionResolver
return resolvers.SubscriptionResolver
} }
func (r *rootResolver) Log() graphcore.LogResolver { func (r *rootResolver) Log() graphcore.LogResolver {

4
graph2/queries/changes.go → graph2/resolvers/changes.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -10,7 +10,7 @@ import (
/// Queries /// Queries
func (r *resolver) Changes(ctx context.Context, filter *changes.Filter) ([]*models.Change, error) {
func (r *queryResolver) Changes(ctx context.Context, filter *changes.Filter) ([]*models.Change, error) {
changes, err := changes.List(filter) changes, err := changes.List(filter)
if err != nil { if err != nil {
return nil, err return nil, err

6
graph2/queries/channel.go → graph2/resolvers/channel.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -14,7 +14,7 @@ import (
// Queries // Queries
func (r *resolver) Channel(ctx context.Context, name string) (*models.Channel, error) {
func (r *queryResolver) Channel(ctx context.Context, name string) (*models.Channel, error) {
channel, err := channels.FindName(name) channel, err := channels.FindName(name)
if err != nil { if err != nil {
return nil, err return nil, err
@ -23,7 +23,7 @@ func (r *resolver) Channel(ctx context.Context, name string) (*models.Channel, e
return &channel, nil return &channel, nil
} }
func (r *resolver) Channels(ctx context.Context, filter *channels.Filter) ([]*models.Channel, error) {
func (r *queryResolver) Channels(ctx context.Context, filter *channels.Filter) ([]*models.Channel, error) {
channels, err := channels.List(filter) channels, err := channels.List(filter)
if err != nil { if err != nil {
return nil, err return nil, err

4
graph2/queries/chapter.go → graph2/resolvers/chapter.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -17,7 +17,7 @@ import (
// Queries // Queries
func (r *resolver) Chapter(ctx context.Context, id string) (*models.Chapter, error) {
func (r *queryResolver) Chapter(ctx context.Context, id string) (*models.Chapter, error) {
chapter, err := chapters.FindID(id) chapter, err := chapters.FindID(id)
if err != nil { if err != nil {
return nil, err return nil, err

6
graph2/queries/character.go → graph2/resolvers/character.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -16,7 +16,7 @@ import (
// Queries // Queries
func (r *resolver) Character(ctx context.Context, id *string, nick *string) (*models.Character, error) {
func (r *queryResolver) Character(ctx context.Context, id *string, nick *string) (*models.Character, error) {
if id != nil { if id != nil {
character, err := characters.FindID(*id) character, err := characters.FindID(*id)
if err != nil { if err != nil {
@ -36,7 +36,7 @@ func (r *resolver) Character(ctx context.Context, id *string, nick *string) (*mo
} }
} }
func (r *resolver) Characters(ctx context.Context, filter *characters.Filter) ([]*models.Character, error) {
func (r *queryResolver) Characters(ctx context.Context, filter *characters.Filter) ([]*models.Character, error) {
characters, err := characters.List(filter) characters, err := characters.List(filter)
if err != nil { if err != nil {
return nil, err return nil, err

4
graph2/queries/comment.go → graph2/resolvers/comment.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -19,7 +19,7 @@ import (
// Queries // Queries
func (r *resolver) Comment(ctx context.Context, id string) (*models.Comment, error) {
func (r *queryResolver) Comment(ctx context.Context, id string) (*models.Comment, error) {
comment, err := comments.Find(id) comment, err := comments.Find(id)
if err != nil { if err != nil {
return nil, err return nil, err

6
graph2/queries/file.go → graph2/resolvers/file.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -8,7 +8,7 @@ import (
"git.aiterp.net/rpdata/api/models/files" "git.aiterp.net/rpdata/api/models/files"
) )
func (r *resolver) File(ctx context.Context, id string) (*models.File, error) {
func (r *queryResolver) File(ctx context.Context, id string) (*models.File, error) {
file, err := files.FindID(id) file, err := files.FindID(id)
if err != nil { if err != nil {
return nil, err return nil, err
@ -17,7 +17,7 @@ func (r *resolver) File(ctx context.Context, id string) (*models.File, error) {
return &file, nil return &file, nil
} }
func (r *resolver) Files(ctx context.Context, filter *files.Filter) ([]*models.File, error) {
func (r *queryResolver) Files(ctx context.Context, filter *files.Filter) ([]*models.File, error) {
token := auth.TokenFromContext(ctx) token := auth.TokenFromContext(ctx)
if filter == nil { if filter == nil {

6
graph2/queries/log.go → graph2/resolvers/log.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -19,7 +19,7 @@ import (
// Queries // Queries
func (r *resolver) Log(ctx context.Context, id string) (*models.Log, error) {
func (r *queryResolver) Log(ctx context.Context, id string) (*models.Log, error) {
log, err := logs.FindID(id) log, err := logs.FindID(id)
if err != nil { if err != nil {
return nil, err return nil, err
@ -28,7 +28,7 @@ func (r *resolver) Log(ctx context.Context, id string) (*models.Log, error) {
return &log, nil return &log, nil
} }
func (r *resolver) Logs(ctx context.Context, filter *logs.Filter) ([]*models.Log, error) {
func (r *queryResolver) Logs(ctx context.Context, filter *logs.Filter) ([]*models.Log, error) {
logs, err := logs.List(filter) logs, err := logs.List(filter)
if err != nil { if err != nil {
return nil, err return nil, err

6
graph2/queries/post.go → graph2/resolvers/post.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -15,7 +15,7 @@ import (
// Queries // Queries
func (r *resolver) Post(ctx context.Context, id string) (*models.Post, error) {
func (r *queryResolver) Post(ctx context.Context, id string) (*models.Post, error) {
post, err := posts.FindID(id) post, err := posts.FindID(id)
if err != nil { if err != nil {
return nil, err return nil, err
@ -24,7 +24,7 @@ func (r *resolver) Post(ctx context.Context, id string) (*models.Post, error) {
return &post, nil return &post, nil
} }
func (r *resolver) Posts(ctx context.Context, filter *posts.Filter) ([]*models.Post, error) {
func (r *queryResolver) Posts(ctx context.Context, filter *posts.Filter) ([]*models.Post, error) {
// Some sanity checks to avoid querying an insame amount of posts. // Some sanity checks to avoid querying an insame amount of posts.
if filter == nil { if filter == nil {
filter = &posts.Filter{Limit: 256} filter = &posts.Filter{Limit: 256}

6
graph2/queries/resolver.go → graph2/resolvers/resolvers.go

@ -1,17 +1,17 @@
package queries
package resolvers
import ( import (
"git.aiterp.net/rpdata/api/graph2/graphcore" "git.aiterp.net/rpdata/api/graph2/graphcore"
"git.aiterp.net/rpdata/api/services" "git.aiterp.net/rpdata/api/services"
) )
type resolver struct{ s *services.Bundle }
type queryResolver struct{ s *services.Bundle }
type mutationResolver struct{} type mutationResolver struct{}
type subscriptionResolver struct{} type subscriptionResolver struct{}
// QueryResolver has all the queries // QueryResolver has all the queries
func QueryResolver(s *services.Bundle) graphcore.QueryResolver { func QueryResolver(s *services.Bundle) graphcore.QueryResolver {
return &resolver{s: s}
return &queryResolver{s: s}
} }
// MutationResolver brings the mutagens. // MutationResolver brings the mutagens.

6
graph2/queries/story.go → graph2/resolvers/story.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -14,7 +14,7 @@ import (
"git.aiterp.net/rpdata/api/models/stories" "git.aiterp.net/rpdata/api/models/stories"
) )
func (r *resolver) Story(ctx context.Context, id string) (*models.Story, error) {
func (r *queryResolver) Story(ctx context.Context, id string) (*models.Story, error) {
story, err := stories.FindID(id) story, err := stories.FindID(id)
if err != nil { if err != nil {
return nil, err return nil, err
@ -23,7 +23,7 @@ func (r *resolver) Story(ctx context.Context, id string) (*models.Story, error)
return &story, nil return &story, nil
} }
func (r *resolver) Stories(ctx context.Context, filter *stories.Filter) ([]*models.Story, error) {
func (r *queryResolver) Stories(ctx context.Context, filter *stories.Filter) ([]*models.Story, error) {
if filter != nil { if filter != nil {
if filter.Unlisted != nil && *filter.Unlisted == true { if filter.Unlisted != nil && *filter.Unlisted == true {
token := auth.TokenFromContext(ctx) token := auth.TokenFromContext(ctx)

4
graph2/queries/tags.go → graph2/resolvers/tags.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -7,7 +7,7 @@ import (
"git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models"
) )
func (r *resolver) Tags(ctx context.Context, filter *graphcore.TagFilter) ([]*models.Tag, error) {
func (r *queryResolver) Tags(ctx context.Context, filter *graphcore.TagFilter) ([]*models.Tag, error) {
tagFilter := models.TagFilter{} tagFilter := models.TagFilter{}
if filter != nil && filter.Kind != nil { if filter != nil && filter.Kind != nil {
tagFilter.Kind = filter.Kind tagFilter.Kind = filter.Kind

4
graph2/queries/token.go → graph2/resolvers/token.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -8,7 +8,7 @@ import (
"git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models"
) )
func (r *resolver) Token(ctx context.Context) (*models.Token, error) {
func (r *queryResolver) Token(ctx context.Context) (*models.Token, error) {
token := auth.TokenFromContext(ctx) token := auth.TokenFromContext(ctx)
if !token.Authenticated() { if !token.Authenticated() {
return nil, errors.New("No (valid) token") return nil, errors.New("No (valid) token")

4
graph2/queries/unknownnicks.go → graph2/resolvers/unknownnicks.go

@ -1,4 +1,4 @@
package queries
package resolvers
import ( import (
"context" "context"
@ -10,7 +10,7 @@ import (
/// Queries /// Queries
func (r *resolver) UnknownNicks(ctx context.Context, filter *graphcore.UnknownNicksFilter) ([]*models.UnknownNick, error) {
func (r *queryResolver) UnknownNicks(ctx context.Context, filter *graphcore.UnknownNicksFilter) ([]*models.UnknownNick, error) {
limit := 100 limit := 100
if filter != nil { if filter != nil {
if filter.Limit > 0 { if filter.Limit > 0 {
Loading…
Cancel
Save