Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql, Web: use refname on pull and push #348

Merged
merged 4 commits into from
Jan 6, 2025
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
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 @@ -400,14 +400,14 @@
async restoreAllTables(args: t.RefArgs): t.PR {
return this.queryQR(
async qr => {
console.log("[restore_all]: starting transaction");

Check warning on line 403 in graphql-server/src/queryFactory/dolt/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
await qr.query("BEGIN");

console.log("[restore_all]: calling");

Check warning on line 406 in graphql-server/src/queryFactory/dolt/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
const res = await qr.query(qh.callResetHard);

if (res.length && res[0].status !== "0") {
console.log("[restore_all]: reset not successful, rolling back");

Check warning on line 410 in graphql-server/src/queryFactory/dolt/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
await qr.query("ROLLBACK");
throw new Error("Reset --hard not successful");
}
Expand All @@ -417,12 +417,12 @@

if (status.length) {
status.forEach(async r => {
console.log("[restore_all]: checking out new table", r.table_name);

Check warning on line 420 in graphql-server/src/queryFactory/dolt/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
const checkRes = await qr.query(qh.callCheckoutTable, [
r.table_name,
]);
if (checkRes.length && checkRes[0].status !== "0") {
console.log(

Check warning on line 425 in graphql-server/src/queryFactory/dolt/index.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected console statement
"[restore_all]: checkout not successful, rolling back",
);
await qr.query("ROLLBACK");
Expand Down Expand Up @@ -470,6 +470,7 @@
qh.callPullRemote,
[args.remoteName, args.branchName],
args.databaseName,
args.refName,
);
}

Expand All @@ -478,6 +479,7 @@
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
Loading