Skip to content

Commit

Permalink
Merge pull request #348 from dolthub/liuliu/pass-refname-on-pull-and-…
Browse files Browse the repository at this point in the history
…push

Graphql, Web: use refname on pull and push
  • Loading branch information
liuliu-dev authored Jan 6, 2025
2 parents 1eb0744 + a97fbce commit fbeefcb
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions graphql-server/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ type Mutation {
mergePull(fromBranchName: String!, toBranchName: String!, databaseName: String!, author: AuthorInfo): Boolean!
addRemote(remoteName: String!, databaseName: String!, remoteUrl: String!): String!
deleteRemote(databaseName: String!, remoteName: String!): Boolean!
pullFromRemote(remoteName: String!, databaseName: String!, branchName: String!): PullRes!
pushToRemote(remoteName: String!, databaseName: String!, branchName: String!): PushRes!
pullFromRemote(remoteName: String!, databaseName: String!, refName: String!, branchName: String!): PullRes!
pushToRemote(remoteName: String!, databaseName: String!, refName: String!, branchName: String!): PushRes!
restoreAllTables(databaseName: String!, refName: String!): Boolean!
createTag(tagName: String!, databaseName: String!, message: String, fromRefName: String!, author: AuthorInfo): String!
deleteTag(databaseName: String!, tagName: String!): Boolean!
Expand Down
2 changes: 2 additions & 0 deletions graphql-server/src/queryFactory/dolt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ export class DoltQueryFactory
qh.callPullRemote,
[args.remoteName, args.branchName],
args.databaseName,
args.refName,
);
}

Expand All @@ -478,6 +479,7 @@ export class DoltQueryFactory
qh.callPushRemote,
[args.remoteName, args.branchName],
args.databaseName,
args.refName,
);
}

Expand Down
2 changes: 2 additions & 0 deletions graphql-server/src/queryFactory/doltgres/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ export class DoltgresQueryFactory
qh.callPullRemote,
[args.remoteName, args.branchName],
args.databaseName,
args.refName,
);
}

Expand All @@ -469,6 +470,7 @@ export class DoltgresQueryFactory
qh.callPushRemote,
[args.remoteName, args.branchName],
args.databaseName,
args.refName,
);
}

Expand Down
5 changes: 4 additions & 1 deletion graphql-server/src/queryFactory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ export type RefMaybeSchemaArgs = RefArgs & { schemaName?: string };
export type BranchArgs = DBArgs & { branchName: string };
export type RemoteArgs = DBArgs & { remoteName: string };
export type AddRemoteArgs = RemoteArgs & { remoteUrl: string };
export type RemoteMaybeBranchArgs = RemoteArgs & { branchName?: string };
export type RemoteMaybeBranchArgs = RemoteArgs & {
refName: string;
branchName?: string;
};
export type TagArgs = DBArgs & { tagName: string };
export type TableArgs = RefArgs & { tableName: string };
export type TableMaybeSchemaArgs = TableArgs & { schemaName?: string };
Expand Down
3 changes: 3 additions & 0 deletions graphql-server/src/remotes/remote.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export class AddRemoteArgs extends RemoteArgs {

@ArgsType()
export class PullOrPushRemoteArgs extends RemoteArgs {
@Field()
refName: string;

@Field()
branchName: string;
}
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "dolt-workbench",
"description": "SQL workbench for MySQL and PostgreSQL databases",
"version": "0.3.0",
"version": "0.3.6",
"main": "app/background.js",
"author": "DoltHub",
"packageManager": "yarn@4.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export const PULL_FROM_REMOTE = gql`
$remoteName: String!
$branchName: String!
$databaseName: String!
$refName: String!
) {
pullFromRemote(
remoteName: $remoteName
branchName: $branchName
databaseName: $databaseName
refName: $refName
) {
...PullRes
}
Expand All @@ -53,11 +55,13 @@ export const PUSH_TO_REMOTE = gql`
$remoteName: String!
$branchName: String!
$databaseName: String!
$refName: String!
) {
pushToRemote(
remoteName: $remoteName
branchName: $branchName
databaseName: $databaseName
refName: $refName
) {
...PushRes
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function usePullFromRemote(
databaseName: params.databaseName,
remoteName: remote.name,
branchName: remoteBranchName,
refName: params.refName,
},
});
if (!pullRes.data) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function usePushToRemote(
branchName: remoteBranch
? `${state.branchName}:${remoteBranch}`
: state.branchName,
refName: state.branchName,
},
});
setState({ loading: false });
Expand Down
12 changes: 10 additions & 2 deletions web/renderer/gen/graphql-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,15 @@ export type MutationMergePullArgs = {
export type MutationPullFromRemoteArgs = {
branchName: Scalars['String']['input'];
databaseName: Scalars['String']['input'];
refName: Scalars['String']['input'];
remoteName: Scalars['String']['input'];
};


export type MutationPushToRemoteArgs = {
branchName: Scalars['String']['input'];
databaseName: Scalars['String']['input'];
refName: Scalars['String']['input'];
remoteName: Scalars['String']['input'];
};

Expand Down Expand Up @@ -1324,6 +1326,7 @@ export type PullFromRemoteMutationVariables = Exact<{
remoteName: Scalars['String']['input'];
branchName: Scalars['String']['input'];
databaseName: Scalars['String']['input'];
refName: Scalars['String']['input'];
}>;


Expand All @@ -1335,6 +1338,7 @@ export type PushToRemoteMutationVariables = Exact<{
remoteName: Scalars['String']['input'];
branchName: Scalars['String']['input'];
databaseName: Scalars['String']['input'];
refName: Scalars['String']['input'];
}>;


Expand Down Expand Up @@ -3902,11 +3906,12 @@ export type DeleteRemoteMutationHookResult = ReturnType<typeof useDeleteRemoteMu
export type DeleteRemoteMutationResult = Apollo.MutationResult<DeleteRemoteMutation>;
export type DeleteRemoteMutationOptions = Apollo.BaseMutationOptions<DeleteRemoteMutation, DeleteRemoteMutationVariables>;
export const PullFromRemoteDocument = gql`
mutation PullFromRemote($remoteName: String!, $branchName: String!, $databaseName: String!) {
mutation PullFromRemote($remoteName: String!, $branchName: String!, $databaseName: String!, $refName: String!) {
pullFromRemote(
remoteName: $remoteName
branchName: $branchName
databaseName: $databaseName
refName: $refName
) {
...PullRes
}
Expand All @@ -3930,6 +3935,7 @@ export type PullFromRemoteMutationFn = Apollo.MutationFunction<PullFromRemoteMut
* remoteName: // value for 'remoteName'
* branchName: // value for 'branchName'
* databaseName: // value for 'databaseName'
* refName: // value for 'refName'
* },
* });
*/
Expand All @@ -3941,11 +3947,12 @@ export type PullFromRemoteMutationHookResult = ReturnType<typeof usePullFromRemo
export type PullFromRemoteMutationResult = Apollo.MutationResult<PullFromRemoteMutation>;
export type PullFromRemoteMutationOptions = Apollo.BaseMutationOptions<PullFromRemoteMutation, PullFromRemoteMutationVariables>;
export const PushToRemoteDocument = gql`
mutation PushToRemote($remoteName: String!, $branchName: String!, $databaseName: String!) {
mutation PushToRemote($remoteName: String!, $branchName: String!, $databaseName: String!, $refName: String!) {
pushToRemote(
remoteName: $remoteName
branchName: $branchName
databaseName: $databaseName
refName: $refName
) {
...PushRes
}
Expand All @@ -3969,6 +3976,7 @@ export type PushToRemoteMutationFn = Apollo.MutationFunction<PushToRemoteMutatio
* remoteName: // value for 'remoteName'
* branchName: // value for 'branchName'
* databaseName: // value for 'databaseName'
* refName: // value for 'refName'
* },
* });
*/
Expand Down

0 comments on commit fbeefcb

Please sign in to comment.