chore: add apps from go.sour.is/ev
This commit is contained in:
37
app/gql/common.graphqls
Normal file
37
app/gql/common.graphqls
Normal file
@@ -0,0 +1,37 @@
|
||||
scalar Time
|
||||
scalar Map
|
||||
|
||||
type Connection @goModel(model: "go.sour.is/pkg/gql.Connection") {
|
||||
paging: PageInfo!
|
||||
edges: [Edge!]!
|
||||
}
|
||||
input PageInput @goModel(model: "go.sour.is/pkg/gql.PageInput") {
|
||||
after: Int = 0
|
||||
before: Int
|
||||
count: Int = 30
|
||||
}
|
||||
type PageInfo @goModel(model: "go.sour.is/pkg/gql.PageInfo") {
|
||||
next: Boolean!
|
||||
prev: Boolean!
|
||||
|
||||
begin: Int!
|
||||
end: Int!
|
||||
}
|
||||
interface Edge @goModel(model: "go.sour.is/pkg/gql.Edge"){
|
||||
id: ID!
|
||||
}
|
||||
|
||||
directive @goModel(
|
||||
model: String
|
||||
models: [String!]
|
||||
) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
|
||||
|
||||
directive @goField(
|
||||
forceResolver: Boolean
|
||||
name: String
|
||||
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
|
||||
|
||||
directive @goTag(
|
||||
key: String!
|
||||
value: String
|
||||
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
|
||||
34
app/gql/eventstore.graphqls
Normal file
34
app/gql/eventstore.graphqls
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
type Meta @goModel(model: "go.sour.is/ev/pkg/event.Meta") {
|
||||
eventID: String! @goField(name: "getEventID")
|
||||
streamID: String! @goField(name: "ActualStreamID")
|
||||
position: Int! @goField(name: "ActualPosition")
|
||||
created: Time!
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
events(streamID: String! paging: PageInput): Connection!
|
||||
}
|
||||
extend type Mutation {
|
||||
truncateStream(streamID: String! index:Int!): Boolean!
|
||||
}
|
||||
extend type Subscription {
|
||||
"""after == 0 start from begining, after == -1 start from end"""
|
||||
eventAdded(streamID: String! after: Int! = -1): Event
|
||||
}
|
||||
|
||||
type Event implements Edge @goModel(model: "go.sour.is/ev/pkg/gql.Event") {
|
||||
id: ID!
|
||||
|
||||
eventID: String!
|
||||
streamID: String!
|
||||
position: Int!
|
||||
|
||||
values: Map!
|
||||
bytes: String!
|
||||
type: String!
|
||||
created: Time!
|
||||
meta: Meta!
|
||||
|
||||
linked: Event
|
||||
}
|
||||
66
app/gql/resolver.go
Normal file
66
app/gql/resolver.go
Normal file
@@ -0,0 +1,66 @@
|
||||
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")
|
||||
}
|
||||
Reference in New Issue
Block a user