a8n: Align API for previews and external changesets
Created by: eseliger
I know I signed this off earlier, but it turns out there are quite a few places where ChangesetPlan
and ExternalChangeset
are used in the same context, but they currently are not very similar in their structure.
For example, in the WebApp we have to always check the __typename
property before we can use the diff:
const diffStat = campaign
? campaign.__typename === 'CampaignPlan'
? campaign.diff.fileDiffs.diffStat
: campaign.fileDiffs.diffStat
: null
current schema
type ChangesetPlan {
repository: Repository!
fileDiffs(first: Int): PreviewFileDiffConnection!
}
type PreviewFileDiffConnection {
nodes: [PreviewFileDiff!]!
totalCount: Int
pageInfo: PageInfo!
diffStat: DiffStat!
rawDiff: String!
}
type ExternalChangeset {
repository: Repository!
diff: RepositoryComparison
... others
}
type RepositoryComparison {
baseRepository: Repository!
headRepository: Repository!
range: GitRevisionRange!
commits(first: Int): GitCommitConnection!
fileDiffs(first: Int): FileDiffConnection!
}
type FileDiffConnection {
nodes: [FileDiff!]!
totalCount: Int
pageInfo: PageInfo!
diffStat: DiffStat!
rawDiff: String!
}
If we would reintroduce the RepositoryComparison
on the preview level, the structure would be more aligned and it would help a lot creating more broadly usable components for both previews and actual campaigns/changesets :)
So I'm suggesting here that we reintroduce
type PreviewRepositoryComparison {
baseRepository: Repository!
fileDiffs(first: Int): PreviewFileDiffConnection!
}