package gql

import (
	"context"

	"github.com/99designs/gqlgen/graphql"
	"go.sour.is/pkg/gql"
	"go.sour.is/pkg/gql/resolver"
	gql_es "go.sour.is/ev/gql"

	"go.sour.is/tools/app/msgbus"
	"go.sour.is/tools/app/salty"
	"go.sour.is/tools/internal/graph/generated"
)

type Resolver struct {
	msgbus.MsgbusResolver
	salty.SaltyResolver
	gql_es.EventResolver
}

// Query returns generated.QueryResolver implementation.
func (r *Resolver) Query() generated.QueryResolver { return r }

// Query returns generated.QueryResolver implementation.
func (r *Resolver) Mutation() generated.MutationResolver { return r }

// Subscription returns generated.SubscriptionResolver implementation.
func (r *Resolver) Subscription() generated.SubscriptionResolver { return r }

// func (r *Resolver) isResolver() {}
func (r *Resolver) ExecutableSchema() graphql.ExecutableSchema {
	return generated.NewExecutableSchema(generated.Config{Resolvers: r})
}
func (r *Resolver) BaseResolver() resolver.IsResolver {
	return &noop{}
}

type noop struct{}

var _ msgbus.MsgbusResolver = (*noop)(nil)
var _ salty.SaltyResolver = (*noop)(nil)
var _ gql_es.EventResolver = (*noop)(nil)

func (*noop) IsResolver() {}
func (*noop) CreateSaltyUser(ctx context.Context, nick string, pubkey string) (*salty.SaltyUser, error) {
	panic("not implemented")
}
func (*noop) Posts(ctx context.Context, name, tag string, paging *gql.PageInput) (*gql.Connection, error) {
	panic("not implemented")
}
func (*noop) SaltyUser(ctx context.Context, nick string) (*salty.SaltyUser, error) {
	panic("not implemented")
}
func (*noop) PostAdded(ctx context.Context, name, tag string, after int64) (<-chan *msgbus.PostEvent, error) {
	panic("not implemented")
}
func (*noop) Events(ctx context.Context, streamID string, paging *gql.PageInput) (*gql.Connection, error) {
	panic("not implemented")
}
func (*noop) EventAdded(ctx context.Context, streamID string, after int64) (<-chan *gql_es.Event, error) {
	panic("not implemented")
}
func (*noop) TruncateStream(ctx context.Context, streamID string, index int64) (bool, error) {
	panic("not implemented")
}
