Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Implement minimal resolvers to incorporate schema changes #12215

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions cmd/frontend/graphqlbackend/campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ type CreateCampaignSpecArgs struct {
ChangesetSpecs []graphql.ID
}

type ChangesetSpecsConnectionArgs struct {
First *int32
After *string
}

type CampaignsResolver interface {
// Mutations
CreateCampaign(ctx context.Context, args *CreateCampaignArgs) (CampaignResolver, error)
Expand All @@ -69,7 +74,6 @@ type CampaignsResolver interface {
DeleteCampaign(ctx context.Context, args *DeleteCampaignArgs) (*EmptyResponse, error)
CreateChangesetSpec(ctx context.Context, args *CreateChangesetSpecArgs) (ChangesetSpecResolver, error)
CreateCampaignSpec(ctx context.Context, args *CreateCampaignSpecArgs) (CampaignSpecResolver, error)
// ComputeCampaignDelta(ctx context.Context, args *ComputeCampaignDeltaArgs) (CampaignDeltaResolver, error)
SyncChangeset(ctx context.Context, args *SyncChangesetArgs) (*EmptyResponse, error)

// Queries
Expand All @@ -86,23 +90,51 @@ type CampaignSpecResolver interface {

OriginalInput() (string, error)
ParsedInput() (JSONValue, error)
ChangesetSpecs(context.Context) ([]ChangesetSpecResolver, error)
ChangesetSpecs(ctx context.Context, args *ChangesetSpecsConnectionArgs) (ChangesetSpecConnectionResolver, error)

Description() CampaignDescriptionResolver

Creator(context.Context) (*UserResolver, error)
CreatedAt() *DateTime
CreatedAt() DateTime
Namespace(context.Context) (*NamespaceResolver, error)

ExpiresAt() *DateTime

PreviewURL() (string, error)

ViewerCanAdminister() bool
}

type CampaignDescriptionResolver interface {
Name() string
Description() string
}

type ChangesetSpecConnectionResolver interface {
TotalCount(ctx context.Context) (int32, error)
PageInfo(ctx context.Context) (*graphqlutil.PageInfo, error)
Nodes(ctx context.Context) ([]ChangesetSpecResolver, error)
}

type ChangesetSpecResolver interface {
ID() graphql.ID

Description() ChangesetDescription
Type() campaigns.ChangesetSpecType

ExpiresAt() *DateTime

ToHiddenChangesetSpec() (HiddenChangesetSpecResolver, bool)
ToVisibleChangesetSpec() (VisibleChangesetSpecResolver, bool)
}

type HiddenChangesetSpecResolver interface {
ChangesetSpecResolver
}

type VisibleChangesetSpecResolver interface {
ChangesetSpecResolver

Description(ctx context.Context) (ChangesetDescription, error)
}

type ChangesetDescription interface {
Expand All @@ -111,21 +143,23 @@ type ChangesetDescription interface {
}

type ExistingChangesetReferenceResolver interface {
BaseRepository() graphql.ID
BaseRepository() *RepositoryResolver
ExternalID() string
}

type GitBranchChangesetDescriptionResolver interface {
BaseRepository() graphql.ID
BaseRepository() *RepositoryResolver
BaseRef() string
BaseRev() string

HeadRepository() graphql.ID
HeadRepository() *RepositoryResolver
HeadRef() string

Title() string
Body() string

Diff(ctx context.Context) (*RepositoryComparisonResolver, error)

Commits() []GitCommitDescriptionResolver

Published() bool
Expand All @@ -136,14 +170,6 @@ type GitCommitDescriptionResolver interface {
Diff() string
}

type CampaignDeltaResolver interface {
ID() (graphql.ID, error)

// TODO: More fields, see PR

CreatedAt() DateTime
}

type ChangesetCountsArgs struct {
From *DateTime
To *DateTime
Expand Down
16 changes: 11 additions & 5 deletions cmd/frontend/graphqlbackend/graphqlbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,20 @@ func (r *NodeResolver) ToCampaignSpec() (CampaignSpecResolver, bool) {
return n, ok
}

func (r *NodeResolver) ToChangesetSpec() (ChangesetSpecResolver, bool) {
func (r *NodeResolver) ToHiddenChangesetSpec() (HiddenChangesetSpecResolver, bool) {
n, ok := r.Node.(ChangesetSpecResolver)
return n, ok
if !ok {
return nil, ok
}
return n.ToHiddenChangesetSpec()
}

func (r *NodeResolver) ToCampaignDelta() (CampaignDeltaResolver, bool) {
n, ok := r.Node.(CampaignDeltaResolver)
return n, ok
func (r *NodeResolver) ToVisibleChangesetSpec() (VisibleChangesetSpecResolver, bool) {
n, ok := r.Node.(ChangesetSpecResolver)
if !ok {
return nil, ok
}
return n.ToVisibleChangesetSpec()
}

func (r *NodeResolver) ToProductLicense() (ProductLicense, bool) {
Expand Down
105 changes: 78 additions & 27 deletions cmd/frontend/graphqlbackend/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading