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

Commit

Permalink
Implement minimal resolvers to incorporate schema changes (#12215)
Browse files Browse the repository at this point in the history
  • Loading branch information
eseliger authored Jul 15, 2020
1 parent 3fb117f commit 157d560
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 127 deletions.
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

0 comments on commit 157d560

Please sign in to comment.