feat(server): project.version query for easier cross server sync
This commit is contained in:
@@ -1437,6 +1437,8 @@ export type Project = {
|
||||
sourceApps: Array<Scalars['String']>;
|
||||
team: Array<ProjectCollaborator>;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
/** Retrieve a specific project version by its ID */
|
||||
version?: Maybe<Version>;
|
||||
/** Returns a flat list of all project versions */
|
||||
versions: VersionCollection;
|
||||
/** Return metadata about resources being requested in the viewer */
|
||||
@@ -1482,6 +1484,11 @@ export type ProjectPendingImportedModelsArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionArgs = {
|
||||
id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionsArgs = {
|
||||
cursor?: InputMaybe<Scalars['String']>;
|
||||
limit?: Scalars['Int'];
|
||||
@@ -2076,6 +2083,8 @@ export type ServerInfo = {
|
||||
description?: Maybe<Scalars['String']>;
|
||||
guestModeEnabled: Scalars['Boolean'];
|
||||
inviteOnly?: Maybe<Scalars['Boolean']>;
|
||||
/** Server relocation / migration info */
|
||||
migration?: Maybe<ServerMigration>;
|
||||
name: Scalars['String'];
|
||||
/** @deprecated Use role constants from the @speckle/shared npm package instead */
|
||||
roles: Array<Role>;
|
||||
@@ -2109,6 +2118,12 @@ export type ServerInviteCreateInput = {
|
||||
serverRole?: InputMaybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export type ServerMigration = {
|
||||
__typename?: 'ServerMigration';
|
||||
movedFrom?: Maybe<Scalars['String']>;
|
||||
movedTo?: Maybe<Scalars['String']>;
|
||||
};
|
||||
|
||||
export enum ServerRole {
|
||||
ServerAdmin = 'SERVER_ADMIN',
|
||||
ServerArchivedUser = 'SERVER_ARCHIVED_USER',
|
||||
|
||||
@@ -35,6 +35,11 @@ extend type Project {
|
||||
Returns a flat list of all project versions
|
||||
"""
|
||||
versions(limit: Int! = 25, cursor: String): VersionCollection!
|
||||
|
||||
"""
|
||||
Retrieve a specific project version by its ID
|
||||
"""
|
||||
version(id: String!): Version
|
||||
}
|
||||
|
||||
input ProjectModelsTreeFilter {
|
||||
|
||||
@@ -1450,6 +1450,8 @@ export type Project = {
|
||||
sourceApps: Array<Scalars['String']>;
|
||||
team: Array<ProjectCollaborator>;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
/** Retrieve a specific project version by its ID */
|
||||
version?: Maybe<Version>;
|
||||
/** Returns a flat list of all project versions */
|
||||
versions: VersionCollection;
|
||||
/** Return metadata about resources being requested in the viewer */
|
||||
@@ -1495,6 +1497,11 @@ export type ProjectPendingImportedModelsArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionArgs = {
|
||||
id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionsArgs = {
|
||||
cursor?: InputMaybe<Scalars['String']>;
|
||||
limit?: Scalars['Int'];
|
||||
@@ -3884,6 +3891,7 @@ export type ProjectResolvers<ContextType = GraphQLContext, ParentType extends Re
|
||||
sourceApps?: Resolver<Array<ResolversTypes['String']>, ParentType, ContextType>;
|
||||
team?: Resolver<Array<ResolversTypes['ProjectCollaborator']>, ParentType, ContextType>;
|
||||
updatedAt?: Resolver<ResolversTypes['DateTime'], ParentType, ContextType>;
|
||||
version?: Resolver<Maybe<ResolversTypes['Version']>, ParentType, ContextType, RequireFields<ProjectVersionArgs, 'id'>>;
|
||||
versions?: Resolver<ResolversTypes['VersionCollection'], ParentType, ContextType, RequireFields<ProjectVersionsArgs, 'limit'>>;
|
||||
viewerResources?: Resolver<Array<ResolversTypes['ViewerResourceGroup']>, ParentType, ContextType, RequireFields<ProjectViewerResourcesArgs, 'loadedVersionsOnly' | 'resourceIdString'>>;
|
||||
visibility?: Resolver<ResolversTypes['ProjectVisibility'], ParentType, ContextType>;
|
||||
|
||||
@@ -14,6 +14,13 @@ import { CommitUpdateError } from '@/modules/core/errors/commit'
|
||||
import { updateCommitAndNotify } from '@/modules/core/services/commit/management'
|
||||
|
||||
export = {
|
||||
Project: {
|
||||
async version(parent, args, ctx) {
|
||||
return await ctx.loaders.streams.getStreamCommit
|
||||
.forStream(parent.id)
|
||||
.load(args.id)
|
||||
}
|
||||
},
|
||||
Version: {
|
||||
async authorUser(parent, _args, ctx) {
|
||||
const { author } = parent
|
||||
|
||||
@@ -68,6 +68,7 @@ export type ProjectGraphQLReturn = StreamRecord &
|
||||
| 'allowPublicComments'
|
||||
| 'pendingImportedModels'
|
||||
| 'webhooks'
|
||||
| 'version'
|
||||
> & {
|
||||
/**
|
||||
* Some queries resolve the role, some don't. If role isn't returned, no worries, it'll
|
||||
|
||||
@@ -26,6 +26,7 @@ import { Nullable } from '@/modules/shared/helpers/typeHelper'
|
||||
import { ServerInviteRecord } from '@/modules/serverinvites/helpers/types'
|
||||
import {
|
||||
getCommitBranches,
|
||||
getCommits,
|
||||
getSpecificBranchCommits,
|
||||
getStreamCommitCounts
|
||||
} from '@/modules/core/repositories/commits'
|
||||
@@ -103,6 +104,35 @@ export function buildRequestLoaders(
|
||||
|
||||
const loaders = {
|
||||
streams: {
|
||||
/**
|
||||
* Get a specific commit of a specific stream. Each stream ID technically has its own loader &
|
||||
* thus its own query.
|
||||
*/
|
||||
getStreamCommit: (() => {
|
||||
type CommitDataLoader = DataLoader<string, Nullable<CommitRecord>>
|
||||
const streamCommitLoaders = new Map<string, CommitDataLoader>()
|
||||
return {
|
||||
clearAll: () => streamCommitLoaders.clear(),
|
||||
forStream(streamId: string): CommitDataLoader {
|
||||
let loader = streamCommitLoaders.get(streamId)
|
||||
if (!loader) {
|
||||
loader = createLoader<string, Nullable<CommitRecord>>(
|
||||
async (commitIds) => {
|
||||
const results = keyBy(
|
||||
await getCommits(commitIds.slice(), { streamId }),
|
||||
'id'
|
||||
)
|
||||
return commitIds.map((i) => results[i] || null)
|
||||
}
|
||||
)
|
||||
streamCommitLoaders.set(streamId, loader)
|
||||
}
|
||||
|
||||
return loader
|
||||
}
|
||||
}
|
||||
})(),
|
||||
|
||||
/**
|
||||
* Get favorite metadata for a specific stream and user
|
||||
*/
|
||||
|
||||
@@ -1440,6 +1440,8 @@ export type Project = {
|
||||
sourceApps: Array<Scalars['String']>;
|
||||
team: Array<ProjectCollaborator>;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
/** Retrieve a specific project version by its ID */
|
||||
version?: Maybe<Version>;
|
||||
/** Returns a flat list of all project versions */
|
||||
versions: VersionCollection;
|
||||
/** Return metadata about resources being requested in the viewer */
|
||||
@@ -1485,6 +1487,11 @@ export type ProjectPendingImportedModelsArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionArgs = {
|
||||
id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionsArgs = {
|
||||
cursor?: InputMaybe<Scalars['String']>;
|
||||
limit?: Scalars['Int'];
|
||||
|
||||
@@ -1441,6 +1441,8 @@ export type Project = {
|
||||
sourceApps: Array<Scalars['String']>;
|
||||
team: Array<ProjectCollaborator>;
|
||||
updatedAt: Scalars['DateTime'];
|
||||
/** Retrieve a specific project version by its ID */
|
||||
version?: Maybe<Version>;
|
||||
/** Returns a flat list of all project versions */
|
||||
versions: VersionCollection;
|
||||
/** Return metadata about resources being requested in the viewer */
|
||||
@@ -1486,6 +1488,11 @@ export type ProjectPendingImportedModelsArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionArgs = {
|
||||
id: Scalars['String'];
|
||||
};
|
||||
|
||||
|
||||
export type ProjectVersionsArgs = {
|
||||
cursor?: InputMaybe<Scalars['String']>;
|
||||
limit?: Scalars['Int'];
|
||||
|
||||
Reference in New Issue
Block a user