api/graph: rename Subscription to ActivitySubscription

The GraphQL "Subscription" type is special and used for defining
subscription operations. Pick a different name so that GraphQL
parsers don't get confused.

References: https://todo.sr.ht/~sircmpwn/sr.ht/302
This commit is contained in:
Simon Ser 2022-01-12 13:29:33 +00:00 committed by Drew DeVault
parent 28496b85cd
commit a1158c25ff
5 changed files with 234 additions and 234 deletions

View File

@ -68,6 +68,11 @@ type ComplexityRoot struct {
Results func(childComplexity int) int
}
ActivitySubscriptionCursor struct {
Cursor func(childComplexity int) int
Results func(childComplexity int) int
}
Assignment struct {
Assignee func(childComplexity int) int
Assigner func(childComplexity int) int
@ -190,11 +195,6 @@ type ComplexityRoot struct {
Ticket func(childComplexity int) int
}
SubscriptionCursor struct {
Cursor func(childComplexity int) int
Results func(childComplexity int) int
}
Ticket struct {
Assignees func(childComplexity int) int
Authenticity func(childComplexity int) int
@ -360,7 +360,7 @@ type QueryResolver interface {
TrackerByName(ctx context.Context, name string) (*model.Tracker, error)
TrackerByOwner(ctx context.Context, owner string, tracker string) (*model.Tracker, error)
Events(ctx context.Context, cursor *model1.Cursor) (*model.EventCursor, error)
Subscriptions(ctx context.Context, cursor *model1.Cursor) (*model.SubscriptionCursor, error)
Subscriptions(ctx context.Context, cursor *model1.Cursor) (*model.ActivitySubscriptionCursor, error)
}
type StatusChangeResolver interface {
Ticket(ctx context.Context, obj *model.StatusChange) (*model.Ticket, error)
@ -439,6 +439,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ACLCursor.Results(childComplexity), true
case "ActivitySubscriptionCursor.cursor":
if e.complexity.ActivitySubscriptionCursor.Cursor == nil {
break
}
return e.complexity.ActivitySubscriptionCursor.Cursor(childComplexity), true
case "ActivitySubscriptionCursor.results":
if e.complexity.ActivitySubscriptionCursor.Results == nil {
break
}
return e.complexity.ActivitySubscriptionCursor.Results(childComplexity), true
case "Assignment.assignee":
if e.complexity.Assignment.Assignee == nil {
break
@ -1144,20 +1158,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.StatusChange.Ticket(childComplexity), true
case "SubscriptionCursor.cursor":
if e.complexity.SubscriptionCursor.Cursor == nil {
break
}
return e.complexity.SubscriptionCursor.Cursor(childComplexity), true
case "SubscriptionCursor.results":
if e.complexity.SubscriptionCursor.Results == nil {
break
}
return e.complexity.SubscriptionCursor.Results(childComplexity), true
case "Ticket.assignees":
if e.complexity.Ticket.Assignees == nil {
break
@ -2080,7 +2080,7 @@ type TicketMention implements EventDetail {
mentioned: Ticket! @access(scope: TICKETS, kind: RO)
}
interface Subscription {
interface ActivitySubscription {
id: Int!
created: Time!
}
@ -2089,7 +2089,7 @@ interface Subscription {
A tracker subscription will notify a participant of all activity for a
tracker, including all new tickets and their events.
"""
type TrackerSubscription implements Subscription {
type TrackerSubscription implements ActivitySubscription {
id: Int!
created: Time!
tracker: Tracker! @access(scope: TRACKERS, kind: RO)
@ -2099,7 +2099,7 @@ type TrackerSubscription implements Subscription {
A ticket subscription will notify a participant when activity occurs on a
ticket.
"""
type TicketSubscription implements Subscription {
type TicketSubscription implements ActivitySubscription {
id: Int!
created: Time!
ticket: Ticket! @access(scope: TICKETS, kind: RO)
@ -2172,8 +2172,8 @@ If there are additional results available, the cursor object may be passed
back into the same endpoint to retrieve another page. If the cursor is null,
there are no remaining results to return.
"""
type SubscriptionCursor {
results: [Subscription!]!
type ActivitySubscriptionCursor {
results: [ActivitySubscription!]!
cursor: Cursor
}
@ -2218,7 +2218,7 @@ type Query {
events(cursor: Cursor): EventCursor @access(scope: EVENTS, kind: RO)
"List of subscriptions of the authenticated user."
subscriptions(cursor: Cursor): SubscriptionCursor @access(scope: SUBSCRIPTIONS, kind: RO)
subscriptions(cursor: Cursor): ActivitySubscriptionCursor @access(scope: SUBSCRIPTIONS, kind: RO)
}
"You may omit any fields to leave them unchanged."
@ -3381,6 +3381,73 @@ func (ec *executionContext) _ACLCursor_cursor(ctx context.Context, field graphql
return ec.marshalOCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋcoreᚑgoᚋmodelᚐCursor(ctx, field.Selections, res)
}
func (ec *executionContext) _ActivitySubscriptionCursor_results(ctx context.Context, field graphql.CollectedField, obj *model.ActivitySubscriptionCursor) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ActivitySubscriptionCursor",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Results, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]model.ActivitySubscription)
fc.Result = res
return ec.marshalNActivitySubscription2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscriptionᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _ActivitySubscriptionCursor_cursor(ctx context.Context, field graphql.CollectedField, obj *model.ActivitySubscriptionCursor) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "ActivitySubscriptionCursor",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Cursor, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*model1.Cursor)
fc.Result = res
return ec.marshalOCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋcoreᚑgoᚋmodelᚐCursor(ctx, field.Selections, res)
}
func (ec *executionContext) _Assignment_eventType(ctx context.Context, field graphql.CollectedField, obj *model.Assignment) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@ -7171,10 +7238,10 @@ func (ec *executionContext) _Query_subscriptions(ctx context.Context, field grap
if tmp == nil {
return nil, nil
}
if data, ok := tmp.(*model.SubscriptionCursor); ok {
if data, ok := tmp.(*model.ActivitySubscriptionCursor); ok {
return data, nil
}
return nil, fmt.Errorf(`unexpected type %T from directive, should be *git.sr.ht/~sircmpwn/todo.sr.ht/api/graph/model.SubscriptionCursor`, tmp)
return nil, fmt.Errorf(`unexpected type %T from directive, should be *git.sr.ht/~sircmpwn/todo.sr.ht/api/graph/model.ActivitySubscriptionCursor`, tmp)
})
if err != nil {
ec.Error(ctx, err)
@ -7183,9 +7250,9 @@ func (ec *executionContext) _Query_subscriptions(ctx context.Context, field grap
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*model.SubscriptionCursor)
res := resTmp.(*model.ActivitySubscriptionCursor)
fc.Result = res
return ec.marshalOSubscriptionCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscriptionCursor(ctx, field.Selections, res)
return ec.marshalOActivitySubscriptionCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscriptionCursor(ctx, field.Selections, res)
}
func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
@ -7560,73 +7627,6 @@ func (ec *executionContext) _StatusChange_newResolution(ctx context.Context, fie
return ec.marshalNTicketResolution2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐTicketResolution(ctx, field.Selections, res)
}
func (ec *executionContext) _SubscriptionCursor_results(ctx context.Context, field graphql.CollectedField, obj *model.SubscriptionCursor) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "SubscriptionCursor",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Results, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
if !graphql.HasFieldError(ctx, fc) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
res := resTmp.([]model.Subscription)
fc.Result = res
return ec.marshalNSubscription2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscriptionᚄ(ctx, field.Selections, res)
}
func (ec *executionContext) _SubscriptionCursor_cursor(ctx context.Context, field graphql.CollectedField, obj *model.SubscriptionCursor) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
fc := &graphql.FieldContext{
Object: "SubscriptionCursor",
Field: field,
Args: nil,
IsMethod: false,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.Cursor, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*model1.Cursor)
fc.Result = res
return ec.marshalOCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋcoreᚑgoᚋmodelᚐCursor(ctx, field.Selections, res)
}
func (ec *executionContext) _Ticket_id(ctx context.Context, field graphql.CollectedField, obj *model.Ticket) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@ -12023,6 +12023,29 @@ func (ec *executionContext) _ACL(ctx context.Context, sel ast.SelectionSet, obj
}
}
func (ec *executionContext) _ActivitySubscription(ctx context.Context, sel ast.SelectionSet, obj model.ActivitySubscription) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
return graphql.Null
case model.TrackerSubscription:
return ec._TrackerSubscription(ctx, sel, &obj)
case *model.TrackerSubscription:
if obj == nil {
return graphql.Null
}
return ec._TrackerSubscription(ctx, sel, obj)
case model.TicketSubscription:
return ec._TicketSubscription(ctx, sel, &obj)
case *model.TicketSubscription:
if obj == nil {
return graphql.Null
}
return ec._TicketSubscription(ctx, sel, obj)
default:
panic(fmt.Errorf("unexpected type %T", obj))
}
}
func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet, obj model.Entity) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
@ -12111,29 +12134,6 @@ func (ec *executionContext) _EventDetail(ctx context.Context, sel ast.SelectionS
}
}
func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet, obj model.Subscription) graphql.Marshaler {
switch obj := (obj).(type) {
case nil:
return graphql.Null
case model.TrackerSubscription:
return ec._TrackerSubscription(ctx, sel, &obj)
case *model.TrackerSubscription:
if obj == nil {
return graphql.Null
}
return ec._TrackerSubscription(ctx, sel, obj)
case model.TicketSubscription:
return ec._TicketSubscription(ctx, sel, &obj)
case *model.TicketSubscription:
if obj == nil {
return graphql.Null
}
return ec._TicketSubscription(ctx, sel, obj)
default:
panic(fmt.Errorf("unexpected type %T", obj))
}
}
// endregion ************************** interface.gotpl ***************************
// region **************************** object.gotpl ****************************
@ -12167,6 +12167,35 @@ func (ec *executionContext) _ACLCursor(ctx context.Context, sel ast.SelectionSet
return out
}
var activitySubscriptionCursorImplementors = []string{"ActivitySubscriptionCursor"}
func (ec *executionContext) _ActivitySubscriptionCursor(ctx context.Context, sel ast.SelectionSet, obj *model.ActivitySubscriptionCursor) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, activitySubscriptionCursorImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("ActivitySubscriptionCursor")
case "results":
out.Values[i] = ec._ActivitySubscriptionCursor_results(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "cursor":
out.Values[i] = ec._ActivitySubscriptionCursor_cursor(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var assignmentImplementors = []string{"Assignment", "EventDetail"}
func (ec *executionContext) _Assignment(ctx context.Context, sel ast.SelectionSet, obj *model.Assignment) graphql.Marshaler {
@ -13031,35 +13060,6 @@ func (ec *executionContext) _StatusChange(ctx context.Context, sel ast.Selection
return out
}
var subscriptionCursorImplementors = []string{"SubscriptionCursor"}
func (ec *executionContext) _SubscriptionCursor(ctx context.Context, sel ast.SelectionSet, obj *model.SubscriptionCursor) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionCursorImplementors)
out := graphql.NewFieldSet(fields)
var invalids uint32
for i, field := range fields {
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("SubscriptionCursor")
case "results":
out.Values[i] = ec._SubscriptionCursor_results(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalids++
}
case "cursor":
out.Values[i] = ec._SubscriptionCursor_cursor(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
out.Dispatch()
if invalids > 0 {
return graphql.Null
}
return out
}
var ticketImplementors = []string{"Ticket"}
func (ec *executionContext) _Ticket(ctx context.Context, sel ast.SelectionSet, obj *model.Ticket) graphql.Marshaler {
@ -13303,7 +13303,7 @@ func (ec *executionContext) _TicketMention(ctx context.Context, sel ast.Selectio
return out
}
var ticketSubscriptionImplementors = []string{"TicketSubscription", "Subscription"}
var ticketSubscriptionImplementors = []string{"TicketSubscription", "ActivitySubscription"}
func (ec *executionContext) _TicketSubscription(ctx context.Context, sel ast.SelectionSet, obj *model.TicketSubscription) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, ticketSubscriptionImplementors)
@ -13618,7 +13618,7 @@ func (ec *executionContext) _TrackerCursor(ctx context.Context, sel ast.Selectio
return out
}
var trackerSubscriptionImplementors = []string{"TrackerSubscription", "Subscription"}
var trackerSubscriptionImplementors = []string{"TrackerSubscription", "ActivitySubscription"}
func (ec *executionContext) _TrackerSubscription(ctx context.Context, sel ast.SelectionSet, obj *model.TrackerSubscription) graphql.Marshaler {
fields := graphql.CollectFields(ec.OperationContext, sel, trackerSubscriptionImplementors)
@ -14133,6 +14133,60 @@ func (ec *executionContext) marshalNAccessScope2gitᚗsrᚗhtᚋאsircmpwnᚋtod
return v
}
func (ec *executionContext) marshalNActivitySubscription2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscription(ctx context.Context, sel ast.SelectionSet, v model.ActivitySubscription) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
return ec._ActivitySubscription(ctx, sel, v)
}
func (ec *executionContext) marshalNActivitySubscription2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscriptionᚄ(ctx context.Context, sel ast.SelectionSet, v []model.ActivitySubscription) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalNActivitySubscription2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscription(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) unmarshalNAuthenticity2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐAuthenticity(ctx context.Context, v interface{}) (model.Authenticity, error) {
var res model.Authenticity
err := res.UnmarshalGQL(v)
@ -14470,60 +14524,6 @@ func (ec *executionContext) unmarshalNSubmitTicketInput2gitᚗsrᚗhtᚋאsircmp
return res, graphql.ErrorOnPath(ctx, err)
}
func (ec *executionContext) marshalNSubscription2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscription(ctx context.Context, sel ast.SelectionSet, v model.Subscription) graphql.Marshaler {
if v == nil {
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
ec.Errorf(ctx, "must not be null")
}
return graphql.Null
}
return ec._Subscription(ctx, sel, v)
}
func (ec *executionContext) marshalNSubscription2ᚕgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscriptionᚄ(ctx context.Context, sel ast.SelectionSet, v []model.Subscription) graphql.Marshaler {
ret := make(graphql.Array, len(v))
var wg sync.WaitGroup
isLen1 := len(v) == 1
if !isLen1 {
wg.Add(len(v))
}
for i := range v {
i := i
fc := &graphql.FieldContext{
Index: &i,
Result: &v[i],
}
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
ret[i] = ec.marshalNSubscription2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscription(ctx, sel, v[i])
}
if isLen1 {
f(i)
} else {
go f(i)
}
}
wg.Wait()
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
return ret
}
func (ec *executionContext) marshalNTicket2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐTicket(ctx context.Context, sel ast.SelectionSet, v model.Ticket) graphql.Marshaler {
return ec._Ticket(ctx, sel, &v)
}
@ -15091,6 +15091,13 @@ func (ec *executionContext) marshalOACL2gitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsr
return ec._ACL(ctx, sel, v)
}
func (ec *executionContext) marshalOActivitySubscriptionCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐActivitySubscriptionCursor(ctx context.Context, sel ast.SelectionSet, v *model.ActivitySubscriptionCursor) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._ActivitySubscriptionCursor(ctx, sel, v)
}
func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) {
res, err := graphql.UnmarshalBoolean(v)
return res, graphql.ErrorOnPath(ctx, err)
@ -15198,13 +15205,6 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
return graphql.MarshalString(*v)
}
func (ec *executionContext) marshalOSubscriptionCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐSubscriptionCursor(ctx context.Context, sel ast.SelectionSet, v *model.SubscriptionCursor) graphql.Marshaler {
if v == nil {
return graphql.Null
}
return ec._SubscriptionCursor(ctx, sel, v)
}
func (ec *executionContext) marshalOTicket2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋtodoᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐTicket(ctx context.Context, sel ast.SelectionSet, v *model.Ticket) graphql.Marshaler {
if v == nil {
return graphql.Null

View File

@ -42,6 +42,16 @@ type ACLInput struct {
Triage bool `json:"triage"`
}
// A cursor for enumerating subscriptions
//
// If there are additional results available, the cursor object may be passed
// back into the same endpoint to retrieve another page. If the cursor is null,
// there are no remaining results to return.
type ActivitySubscriptionCursor struct {
Results []ActivitySubscription `json:"results"`
Cursor *model.Cursor `json:"cursor"`
}
// A cursor for enumerating events
//
// If there are additional results available, the cursor object may be passed
@ -95,16 +105,6 @@ type SubmitTicketInput struct {
ExternalURL *string `json:"externalUrl"`
}
// A cursor for enumerating subscriptions
//
// If there are additional results available, the cursor object may be passed
// back into the same endpoint to retrieve another page. If the cursor is null,
// there are no remaining results to return.
type SubscriptionCursor struct {
Results []Subscription `json:"results"`
Cursor *model.Cursor `json:"cursor"`
}
// A cursor for enumerating tickets
//
// If there are additional results available, the cursor object may be passed

View File

@ -23,7 +23,7 @@ type SubscriptionInfo struct {
fields *database.ModelFields
}
type Subscription interface {
type ActivitySubscription interface {
IsSubscription()
DBID() int
}
@ -86,7 +86,7 @@ func (si *SubscriptionInfo) Fields() *database.ModelFields {
}
func (si *SubscriptionInfo) QueryWithCursor(ctx context.Context, runner sq.BaseRunner,
q sq.SelectBuilder, cur *model.Cursor) ([]Subscription, *model.Cursor) {
q sq.SelectBuilder, cur *model.Cursor) ([]ActivitySubscription, *model.Cursor) {
var (
err error
rows *sql.Rows
@ -105,7 +105,7 @@ func (si *SubscriptionInfo) QueryWithCursor(ctx context.Context, runner sq.BaseR
}
defer rows.Close()
var subs []Subscription
var subs []ActivitySubscription
for rows.Next() {
var si SubscriptionInfo
if err := rows.Scan(database.Scan(ctx, &si)...); err != nil {

View File

@ -341,7 +341,7 @@ type TicketMention implements EventDetail {
mentioned: Ticket! @access(scope: TICKETS, kind: RO)
}
interface Subscription {
interface ActivitySubscription {
id: Int!
created: Time!
}
@ -350,7 +350,7 @@ interface Subscription {
A tracker subscription will notify a participant of all activity for a
tracker, including all new tickets and their events.
"""
type TrackerSubscription implements Subscription {
type TrackerSubscription implements ActivitySubscription {
id: Int!
created: Time!
tracker: Tracker! @access(scope: TRACKERS, kind: RO)
@ -360,7 +360,7 @@ type TrackerSubscription implements Subscription {
A ticket subscription will notify a participant when activity occurs on a
ticket.
"""
type TicketSubscription implements Subscription {
type TicketSubscription implements ActivitySubscription {
id: Int!
created: Time!
ticket: Ticket! @access(scope: TICKETS, kind: RO)
@ -433,8 +433,8 @@ If there are additional results available, the cursor object may be passed
back into the same endpoint to retrieve another page. If the cursor is null,
there are no remaining results to return.
"""
type SubscriptionCursor {
results: [Subscription!]!
type ActivitySubscriptionCursor {
results: [ActivitySubscription!]!
cursor: Cursor
}
@ -479,7 +479,7 @@ type Query {
events(cursor: Cursor): EventCursor @access(scope: EVENTS, kind: RO)
"List of subscriptions of the authenticated user."
subscriptions(cursor: Cursor): SubscriptionCursor @access(scope: SUBSCRIPTIONS, kind: RO)
subscriptions(cursor: Cursor): ActivitySubscriptionCursor @access(scope: SUBSCRIPTIONS, kind: RO)
}
"You may omit any fields to leave them unchanged."

View File

@ -1642,12 +1642,12 @@ func (r *queryResolver) Events(ctx context.Context, cursor *coremodel.Cursor) (*
return &model.EventCursor{events, cursor}, nil
}
func (r *queryResolver) Subscriptions(ctx context.Context, cursor *coremodel.Cursor) (*model.SubscriptionCursor, error) {
func (r *queryResolver) Subscriptions(ctx context.Context, cursor *coremodel.Cursor) (*model.ActivitySubscriptionCursor, error) {
if cursor == nil {
cursor = coremodel.NewCursor(nil)
}
var subs []model.Subscription
var subs []model.ActivitySubscription
if err := database.WithTx(ctx, &sql.TxOptions{}, func(tx *sql.Tx) error {
sub := (&model.SubscriptionInfo{}).As(`sub`)
query := database.
@ -1661,7 +1661,7 @@ func (r *queryResolver) Subscriptions(ctx context.Context, cursor *coremodel.Cur
return nil, err
}
return &model.SubscriptionCursor{subs, cursor}, nil
return &model.ActivitySubscriptionCursor{subs, cursor}, nil
}
func (r *statusChangeResolver) Ticket(ctx context.Context, obj *model.StatusChange) (*model.Ticket, error) {