diff --git a/connect/src/wg/cosmo/platform/v1/platform_pb.ts b/connect/src/wg/cosmo/platform/v1/platform_pb.ts index a5d35dc4e8..536cb85295 100644 --- a/connect/src/wg/cosmo/platform/v1/platform_pb.ts +++ b/connect/src/wg/cosmo/platform/v1/platform_pb.ts @@ -1910,6 +1910,11 @@ export class SchemaCheck extends Message { */ proposedSubgraphSchemaSDL?: string; + /** + * @generated from field: string originalSchemaSDL = 8; + */ + originalSchemaSDL = ""; + constructor(data?: PartialMessage) { super(); proto3.util.initPartial(data, this); @@ -1925,6 +1930,7 @@ export class SchemaCheck extends Message { { no: 5, name: "isComposable", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, { no: 6, name: "isBreaking", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, { no: 7, name: "proposedSubgraphSchemaSDL", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + { no: 8, name: "originalSchemaSDL", kind: "scalar", T: 9 /* ScalarType.STRING */ }, ]); static fromBinary(bytes: Uint8Array, options?: Partial): SchemaCheck { diff --git a/controlplane/drizzle/meta/_journal.json b/controlplane/drizzle/meta/_journal.json new file mode 100644 index 0000000000..5dcbf6ab23 --- /dev/null +++ b/controlplane/drizzle/meta/_journal.json @@ -0,0 +1 @@ +{"version":"5","dialect":"pg","entries":[]} \ No newline at end of file diff --git a/controlplane/migrations/0039_old_wrecking_crew.sql b/controlplane/migrations/0039_old_wrecking_crew.sql new file mode 100644 index 0000000000..137899ea9c --- /dev/null +++ b/controlplane/migrations/0039_old_wrecking_crew.sql @@ -0,0 +1,6 @@ +ALTER TABLE "schema_checks" ADD COLUMN "schema_version_id" uuid NOT NULL;--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "schema_checks" ADD CONSTRAINT "schema_checks_schema_version_id_schema_versions_id_fk" FOREIGN KEY ("schema_version_id") REFERENCES "schema_versions"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/controlplane/migrations/0040_charming_sunfire.sql b/controlplane/migrations/0040_charming_sunfire.sql new file mode 100644 index 0000000000..84506e7410 --- /dev/null +++ b/controlplane/migrations/0040_charming_sunfire.sql @@ -0,0 +1 @@ +ALTER TABLE "schema_checks" ALTER COLUMN "schema_version_id" DROP NOT NULL; \ No newline at end of file diff --git a/controlplane/migrations/meta/0039_snapshot.json b/controlplane/migrations/meta/0039_snapshot.json new file mode 100644 index 0000000000..3c6846f5a0 --- /dev/null +++ b/controlplane/migrations/meta/0039_snapshot.json @@ -0,0 +1,1237 @@ +{ + "version": "5", + "dialect": "pg", + "id": "205ad655-6e31-4e13-88b7-80febe2d0d7c", + "prevId": "2b9ca50f-d51c-4224-9c2a-6305c149865f", + "tables": { + "api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apikey_name_idx": { + "name": "apikey_name_idx", + "columns": [ + "name", + "organization_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "api_keys_user_id_users_id_fk": { + "name": "api_keys_user_id_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "api_keys_organization_id_organizations_id_fk": { + "name": "api_keys_organization_id_organizations_id_fk", + "tableFrom": "api_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_key_unique": { + "name": "api_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + } + }, + "federated_graphs": { + "name": "federated_graphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composed_schema_version_id": { + "name": "composed_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "federated_graphs_target_id_targets_id_fk": { + "name": "federated_graphs_target_id_targets_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_composed_schema_version_id_schema_versions_id_fk": { + "name": "federated_graphs_composed_schema_version_id_schema_versions_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "composed_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "graph_api_tokens": { + "name": "graph_api_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "graph_api_tokens_organization_id_organizations_id_fk": { + "name": "graph_api_tokens_organization_id_organizations_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "graph_api_tokens_federated_graph_id_federated_graphs_id_fk": { + "name": "graph_api_tokens_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "graph_api_tokens_token_unique": { + "name": "graph_api_tokens_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + } + }, + "organization_member_roles": { + "name": "organization_member_roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_member_id": { + "name": "organization_member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "organization_member_roles_organization_member_id_organization_members_id_fk": { + "name": "organization_member_roles_organization_member_id_organization_members_id_fk", + "tableFrom": "organization_member_roles", + "tableTo": "organization_members", + "columnsFrom": [ + "organization_member_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invite_code": { + "name": "invite_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "organizations_user_id_users_id_fk": { + "name": "organizations_user_id_users_id_fk", + "tableFrom": "organizations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + } + }, + "organization_members": { + "name": "organization_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accepted_invite": { + "name": "accepted_invite", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_member_idx": { + "name": "organization_member_idx", + "columns": [ + "id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "organization_members_user_id_users_id_fk": { + "name": "organization_members_user_id_users_id_fk", + "tableFrom": "organization_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_members_organization_id_organizations_id_fk": { + "name": "organization_members_organization_id_organizations_id_fk", + "tableFrom": "organization_members", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_check_change_action": { + "name": "schema_check_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "primaryKey": false, + "notNull": false + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_breaking": { + "name": "is_breaking", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_check_change_action_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_change_action_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_change_action", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_check_composition": { + "name": "schema_check_composition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "composed_schema_sdl": { + "name": "composed_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_check_composition_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_composition_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_composition_target_id_targets_id_fk": { + "name": "schema_check_composition_target_id_targets_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_checks": { + "name": "schema_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_breaking_changes": { + "name": "has_breaking_changes", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "proposed_subgraph_schema_sdl": { + "name": "proposed_subgraph_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "schema_checks_target_id_targets_id_fk": { + "name": "schema_checks_target_id_targets_id_fk", + "tableFrom": "schema_checks", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_checks_schema_version_id_schema_versions_id_fk": { + "name": "schema_checks_schema_version_id_schema_versions_id_fk", + "tableFrom": "schema_checks", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_versions": { + "name": "schema_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "schema_sdl": { + "name": "schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "routerConfig": { + "name": "routerConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_versions_target_id_targets_id_fk": { + "name": "schema_versions_target_id_targets_id_fk", + "tableFrom": "schema_versions", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_version_change_action": { + "name": "schema_version_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "primaryKey": false, + "notNull": true + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_version_change_action_schema_version_id_schema_versions_id_fk": { + "name": "schema_version_change_action_schema_version_id_schema_versions_id_fk", + "tableFrom": "schema_version_change_action", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sessions_user_id_unique": { + "name": "sessions_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + } + }, + "subgraphs": { + "name": "subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "subgraphs_schema_version_id_schema_versions_id_fk": { + "name": "subgraphs_schema_version_id_schema_versions_id_fk", + "tableFrom": "subgraphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "subgraphs_target_id_targets_id_fk": { + "name": "subgraphs_target_id_targets_id_fk", + "tableFrom": "subgraphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "federated_subgraphs": { + "name": "federated_subgraphs", + "schema": "", + "columns": { + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "federated_subgraphs_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_subgraphs_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_subgraphs_subgraph_id_subgraphs_id_fk": { + "name": "federated_subgraphs_subgraph_id_subgraphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "federated_subgraphs_federated_graph_id_subgraph_id": { + "name": "federated_subgraphs_federated_graph_id_subgraph_id", + "columns": [ + "federated_graph_id", + "subgraph_id" + ] + } + }, + "uniqueConstraints": {} + }, + "target_label_matchers": { + "name": "target_label_matchers", + "schema": "", + "columns": { + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label_matcher": { + "name": "label_matcher", + "type": "text[]", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "target_label_matchers_target_id_targets_id_fk": { + "name": "target_label_matchers_target_id_targets_id_fk", + "tableFrom": "target_label_matchers", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "targets": { + "name": "targets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "target_type", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "organization_name_idx": { + "name": "organization_name_idx", + "columns": [ + "organization_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "targets_organization_id_organizations_id_fk": { + "name": "targets_organization_id_organizations_id_fk", + "tableFrom": "targets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + } + } + }, + "enums": { + "member_role": { + "name": "member_role", + "values": { + "admin": "admin", + "member": "member" + } + }, + "schema_change_type": { + "name": "schema_change_type", + "values": { + "FIELD_ARGUMENT_DESCRIPTION_CHANGED": "FIELD_ARGUMENT_DESCRIPTION_CHANGED", + "FIELD_ARGUMENT_DEFAULT_CHANGED": "FIELD_ARGUMENT_DEFAULT_CHANGED", + "FIELD_ARGUMENT_TYPE_CHANGED": "FIELD_ARGUMENT_TYPE_CHANGED", + "DIRECTIVE_REMOVED": "DIRECTIVE_REMOVED", + "DIRECTIVE_ADDED": "DIRECTIVE_ADDED", + "DIRECTIVE_DESCRIPTION_CHANGED": "DIRECTIVE_DESCRIPTION_CHANGED", + "DIRECTIVE_LOCATION_ADDED": "DIRECTIVE_LOCATION_ADDED", + "DIRECTIVE_LOCATION_REMOVED": "DIRECTIVE_LOCATION_REMOVED", + "DIRECTIVE_ARGUMENT_ADDED": "DIRECTIVE_ARGUMENT_ADDED", + "DIRECTIVE_ARGUMENT_REMOVED": "DIRECTIVE_ARGUMENT_REMOVED", + "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED": "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED", + "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED": "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED", + "DIRECTIVE_ARGUMENT_TYPE_CHANGED": "DIRECTIVE_ARGUMENT_TYPE_CHANGED", + "ENUM_VALUE_REMOVED": "ENUM_VALUE_REMOVED", + "ENUM_VALUE_ADDED": "ENUM_VALUE_ADDED", + "ENUM_VALUE_DESCRIPTION_CHANGED": "ENUM_VALUE_DESCRIPTION_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_CHANGED": "ENUM_VALUE_DEPRECATION_REASON_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_ADDED": "ENUM_VALUE_DEPRECATION_REASON_ADDED", + "ENUM_VALUE_DEPRECATION_REASON_REMOVED": "ENUM_VALUE_DEPRECATION_REASON_REMOVED", + "FIELD_REMOVED": "FIELD_REMOVED", + "FIELD_ADDED": "FIELD_ADDED", + "FIELD_DESCRIPTION_CHANGED": "FIELD_DESCRIPTION_CHANGED", + "FIELD_DESCRIPTION_ADDED": "FIELD_DESCRIPTION_ADDED", + "FIELD_DESCRIPTION_REMOVED": "FIELD_DESCRIPTION_REMOVED", + "FIELD_DEPRECATION_ADDED": "FIELD_DEPRECATION_ADDED", + "FIELD_DEPRECATION_REMOVED": "FIELD_DEPRECATION_REMOVED", + "FIELD_DEPRECATION_REASON_CHANGED": "FIELD_DEPRECATION_REASON_CHANGED", + "FIELD_DEPRECATION_REASON_ADDED": "FIELD_DEPRECATION_REASON_ADDED", + "FIELD_DEPRECATION_REASON_REMOVED": "FIELD_DEPRECATION_REASON_REMOVED", + "FIELD_TYPE_CHANGED": "FIELD_TYPE_CHANGED", + "FIELD_ARGUMENT_ADDED": "FIELD_ARGUMENT_ADDED", + "FIELD_ARGUMENT_REMOVED": "FIELD_ARGUMENT_REMOVED", + "INPUT_FIELD_REMOVED": "INPUT_FIELD_REMOVED", + "INPUT_FIELD_ADDED": "INPUT_FIELD_ADDED", + "INPUT_FIELD_DESCRIPTION_ADDED": "INPUT_FIELD_DESCRIPTION_ADDED", + "INPUT_FIELD_DESCRIPTION_REMOVED": "INPUT_FIELD_DESCRIPTION_REMOVED", + "INPUT_FIELD_DESCRIPTION_CHANGED": "INPUT_FIELD_DESCRIPTION_CHANGED", + "INPUT_FIELD_DEFAULT_VALUE_CHANGED": "INPUT_FIELD_DEFAULT_VALUE_CHANGED", + "INPUT_FIELD_TYPE_CHANGED": "INPUT_FIELD_TYPE_CHANGED", + "OBJECT_TYPE_INTERFACE_ADDED": "OBJECT_TYPE_INTERFACE_ADDED", + "OBJECT_TYPE_INTERFACE_REMOVED": "OBJECT_TYPE_INTERFACE_REMOVED", + "SCHEMA_QUERY_TYPE_CHANGED": "SCHEMA_QUERY_TYPE_CHANGED", + "SCHEMA_MUTATION_TYPE_CHANGED": "SCHEMA_MUTATION_TYPE_CHANGED", + "SCHEMA_SUBSCRIPTION_TYPE_CHANGED": "SCHEMA_SUBSCRIPTION_TYPE_CHANGED", + "TYPE_REMOVED": "TYPE_REMOVED", + "TYPE_ADDED": "TYPE_ADDED", + "TYPE_KIND_CHANGED": "TYPE_KIND_CHANGED", + "TYPE_DESCRIPTION_CHANGED": "TYPE_DESCRIPTION_CHANGED", + "TYPE_DESCRIPTION_REMOVED": "TYPE_DESCRIPTION_REMOVED", + "TYPE_DESCRIPTION_ADDED": "TYPE_DESCRIPTION_ADDED", + "UNION_MEMBER_REMOVED": "UNION_MEMBER_REMOVED", + "UNION_MEMBER_ADDED": "UNION_MEMBER_ADDED" + } + }, + "target_type": { + "name": "target_type", + "values": { + "federated": "federated", + "subgraph": "subgraph", + "graph": "graph" + } + } + }, + "schemas": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/controlplane/migrations/meta/0040_snapshot.json b/controlplane/migrations/meta/0040_snapshot.json new file mode 100644 index 0000000000..6ddb5fd77c --- /dev/null +++ b/controlplane/migrations/meta/0040_snapshot.json @@ -0,0 +1,1237 @@ +{ + "version": "5", + "dialect": "pg", + "id": "c699ce95-9a5b-4f8c-942e-bcf2051d4cc0", + "prevId": "205ad655-6e31-4e13-88b7-80febe2d0d7c", + "tables": { + "api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apikey_name_idx": { + "name": "apikey_name_idx", + "columns": [ + "name", + "organization_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "api_keys_user_id_users_id_fk": { + "name": "api_keys_user_id_users_id_fk", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "api_keys_organization_id_organizations_id_fk": { + "name": "api_keys_organization_id_organizations_id_fk", + "tableFrom": "api_keys", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_keys_key_unique": { + "name": "api_keys_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + } + }, + "federated_graphs": { + "name": "federated_graphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composed_schema_version_id": { + "name": "composed_schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "federated_graphs_target_id_targets_id_fk": { + "name": "federated_graphs_target_id_targets_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_graphs_composed_schema_version_id_schema_versions_id_fk": { + "name": "federated_graphs_composed_schema_version_id_schema_versions_id_fk", + "tableFrom": "federated_graphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "composed_schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "graph_api_tokens": { + "name": "graph_api_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "graph_api_tokens_organization_id_organizations_id_fk": { + "name": "graph_api_tokens_organization_id_organizations_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "graph_api_tokens_federated_graph_id_federated_graphs_id_fk": { + "name": "graph_api_tokens_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "graph_api_tokens", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "graph_api_tokens_token_unique": { + "name": "graph_api_tokens_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + } + }, + "organization_member_roles": { + "name": "organization_member_roles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_member_id": { + "name": "organization_member_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "organization_member_roles_organization_member_id_organization_members_id_fk": { + "name": "organization_member_roles_organization_member_id_organization_members_id_fk", + "tableFrom": "organization_member_roles", + "tableTo": "organization_members", + "columnsFrom": [ + "organization_member_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invite_code": { + "name": "invite_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "organizations_user_id_users_id_fk": { + "name": "organizations_user_id_users_id_fk", + "tableFrom": "organizations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organizations_slug_unique": { + "name": "organizations_slug_unique", + "nullsNotDistinct": false, + "columns": [ + "slug" + ] + } + } + }, + "organization_members": { + "name": "organization_members", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "accepted_invite": { + "name": "accepted_invite", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_member_idx": { + "name": "organization_member_idx", + "columns": [ + "id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "organization_members_user_id_users_id_fk": { + "name": "organization_members_user_id_users_id_fk", + "tableFrom": "organization_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_members_organization_id_organizations_id_fk": { + "name": "organization_members_organization_id_organizations_id_fk", + "tableFrom": "organization_members", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_check_change_action": { + "name": "schema_check_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "primaryKey": false, + "notNull": false + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_breaking": { + "name": "is_breaking", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_check_change_action_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_change_action_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_change_action", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_check_composition": { + "name": "schema_check_composition", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_check_id": { + "name": "schema_check_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "composed_schema_sdl": { + "name": "composed_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_check_composition_schema_check_id_schema_checks_id_fk": { + "name": "schema_check_composition_schema_check_id_schema_checks_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "schema_checks", + "columnsFrom": [ + "schema_check_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_check_composition_target_id_targets_id_fk": { + "name": "schema_check_composition_target_id_targets_id_fk", + "tableFrom": "schema_check_composition", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_checks": { + "name": "schema_checks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "has_breaking_changes": { + "name": "has_breaking_changes", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "proposed_subgraph_schema_sdl": { + "name": "proposed_subgraph_schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "schema_checks_target_id_targets_id_fk": { + "name": "schema_checks_target_id_targets_id_fk", + "tableFrom": "schema_checks", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schema_checks_schema_version_id_schema_versions_id_fk": { + "name": "schema_checks_schema_version_id_schema_versions_id_fk", + "tableFrom": "schema_checks", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_versions": { + "name": "schema_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "schema_sdl": { + "name": "schema_sdl", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_composable": { + "name": "is_composable", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "composition_errors": { + "name": "composition_errors", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "routerConfig": { + "name": "routerConfig", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_versions_target_id_targets_id_fk": { + "name": "schema_versions_target_id_targets_id_fk", + "tableFrom": "schema_versions", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "schema_version_change_action": { + "name": "schema_version_change_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "change_type": { + "name": "change_type", + "type": "schema_change_type", + "primaryKey": false, + "notNull": true + }, + "change_message": { + "name": "change_message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "schema_version_change_action_schema_version_id_schema_versions_id_fk": { + "name": "schema_version_change_action_schema_version_id_schema_versions_id_fk", + "tableFrom": "schema_version_change_action", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "sessions_user_id_unique": { + "name": "sessions_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id" + ] + } + } + }, + "subgraphs": { + "name": "subgraphs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "routing_url": { + "name": "routing_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema_version_id": { + "name": "schema_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "subgraphs_schema_version_id_schema_versions_id_fk": { + "name": "subgraphs_schema_version_id_schema_versions_id_fk", + "tableFrom": "subgraphs", + "tableTo": "schema_versions", + "columnsFrom": [ + "schema_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "subgraphs_target_id_targets_id_fk": { + "name": "subgraphs_target_id_targets_id_fk", + "tableFrom": "subgraphs", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "federated_subgraphs": { + "name": "federated_subgraphs", + "schema": "", + "columns": { + "federated_graph_id": { + "name": "federated_graph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "subgraph_id": { + "name": "subgraph_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "federated_subgraphs_federated_graph_id_federated_graphs_id_fk": { + "name": "federated_subgraphs_federated_graph_id_federated_graphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "federated_graphs", + "columnsFrom": [ + "federated_graph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "federated_subgraphs_subgraph_id_subgraphs_id_fk": { + "name": "federated_subgraphs_subgraph_id_subgraphs_id_fk", + "tableFrom": "federated_subgraphs", + "tableTo": "subgraphs", + "columnsFrom": [ + "subgraph_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "federated_subgraphs_federated_graph_id_subgraph_id": { + "name": "federated_subgraphs_federated_graph_id_subgraph_id", + "columns": [ + "federated_graph_id", + "subgraph_id" + ] + } + }, + "uniqueConstraints": {} + }, + "target_label_matchers": { + "name": "target_label_matchers", + "schema": "", + "columns": { + "target_id": { + "name": "target_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label_matcher": { + "name": "label_matcher", + "type": "text[]", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "target_label_matchers_target_id_targets_id_fk": { + "name": "target_label_matchers_target_id_targets_id_fk", + "tableFrom": "target_label_matchers", + "tableTo": "targets", + "columnsFrom": [ + "target_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "targets": { + "name": "targets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "target_type", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "labels": { + "name": "labels", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "organization_name_idx": { + "name": "organization_name_idx", + "columns": [ + "organization_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "targets_organization_id_organizations_id_fk": { + "name": "targets_organization_id_organizations_id_fk", + "tableFrom": "targets", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + } + } + }, + "enums": { + "member_role": { + "name": "member_role", + "values": { + "admin": "admin", + "member": "member" + } + }, + "schema_change_type": { + "name": "schema_change_type", + "values": { + "FIELD_ARGUMENT_DESCRIPTION_CHANGED": "FIELD_ARGUMENT_DESCRIPTION_CHANGED", + "FIELD_ARGUMENT_DEFAULT_CHANGED": "FIELD_ARGUMENT_DEFAULT_CHANGED", + "FIELD_ARGUMENT_TYPE_CHANGED": "FIELD_ARGUMENT_TYPE_CHANGED", + "DIRECTIVE_REMOVED": "DIRECTIVE_REMOVED", + "DIRECTIVE_ADDED": "DIRECTIVE_ADDED", + "DIRECTIVE_DESCRIPTION_CHANGED": "DIRECTIVE_DESCRIPTION_CHANGED", + "DIRECTIVE_LOCATION_ADDED": "DIRECTIVE_LOCATION_ADDED", + "DIRECTIVE_LOCATION_REMOVED": "DIRECTIVE_LOCATION_REMOVED", + "DIRECTIVE_ARGUMENT_ADDED": "DIRECTIVE_ARGUMENT_ADDED", + "DIRECTIVE_ARGUMENT_REMOVED": "DIRECTIVE_ARGUMENT_REMOVED", + "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED": "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED", + "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED": "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED", + "DIRECTIVE_ARGUMENT_TYPE_CHANGED": "DIRECTIVE_ARGUMENT_TYPE_CHANGED", + "ENUM_VALUE_REMOVED": "ENUM_VALUE_REMOVED", + "ENUM_VALUE_ADDED": "ENUM_VALUE_ADDED", + "ENUM_VALUE_DESCRIPTION_CHANGED": "ENUM_VALUE_DESCRIPTION_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_CHANGED": "ENUM_VALUE_DEPRECATION_REASON_CHANGED", + "ENUM_VALUE_DEPRECATION_REASON_ADDED": "ENUM_VALUE_DEPRECATION_REASON_ADDED", + "ENUM_VALUE_DEPRECATION_REASON_REMOVED": "ENUM_VALUE_DEPRECATION_REASON_REMOVED", + "FIELD_REMOVED": "FIELD_REMOVED", + "FIELD_ADDED": "FIELD_ADDED", + "FIELD_DESCRIPTION_CHANGED": "FIELD_DESCRIPTION_CHANGED", + "FIELD_DESCRIPTION_ADDED": "FIELD_DESCRIPTION_ADDED", + "FIELD_DESCRIPTION_REMOVED": "FIELD_DESCRIPTION_REMOVED", + "FIELD_DEPRECATION_ADDED": "FIELD_DEPRECATION_ADDED", + "FIELD_DEPRECATION_REMOVED": "FIELD_DEPRECATION_REMOVED", + "FIELD_DEPRECATION_REASON_CHANGED": "FIELD_DEPRECATION_REASON_CHANGED", + "FIELD_DEPRECATION_REASON_ADDED": "FIELD_DEPRECATION_REASON_ADDED", + "FIELD_DEPRECATION_REASON_REMOVED": "FIELD_DEPRECATION_REASON_REMOVED", + "FIELD_TYPE_CHANGED": "FIELD_TYPE_CHANGED", + "FIELD_ARGUMENT_ADDED": "FIELD_ARGUMENT_ADDED", + "FIELD_ARGUMENT_REMOVED": "FIELD_ARGUMENT_REMOVED", + "INPUT_FIELD_REMOVED": "INPUT_FIELD_REMOVED", + "INPUT_FIELD_ADDED": "INPUT_FIELD_ADDED", + "INPUT_FIELD_DESCRIPTION_ADDED": "INPUT_FIELD_DESCRIPTION_ADDED", + "INPUT_FIELD_DESCRIPTION_REMOVED": "INPUT_FIELD_DESCRIPTION_REMOVED", + "INPUT_FIELD_DESCRIPTION_CHANGED": "INPUT_FIELD_DESCRIPTION_CHANGED", + "INPUT_FIELD_DEFAULT_VALUE_CHANGED": "INPUT_FIELD_DEFAULT_VALUE_CHANGED", + "INPUT_FIELD_TYPE_CHANGED": "INPUT_FIELD_TYPE_CHANGED", + "OBJECT_TYPE_INTERFACE_ADDED": "OBJECT_TYPE_INTERFACE_ADDED", + "OBJECT_TYPE_INTERFACE_REMOVED": "OBJECT_TYPE_INTERFACE_REMOVED", + "SCHEMA_QUERY_TYPE_CHANGED": "SCHEMA_QUERY_TYPE_CHANGED", + "SCHEMA_MUTATION_TYPE_CHANGED": "SCHEMA_MUTATION_TYPE_CHANGED", + "SCHEMA_SUBSCRIPTION_TYPE_CHANGED": "SCHEMA_SUBSCRIPTION_TYPE_CHANGED", + "TYPE_REMOVED": "TYPE_REMOVED", + "TYPE_ADDED": "TYPE_ADDED", + "TYPE_KIND_CHANGED": "TYPE_KIND_CHANGED", + "TYPE_DESCRIPTION_CHANGED": "TYPE_DESCRIPTION_CHANGED", + "TYPE_DESCRIPTION_REMOVED": "TYPE_DESCRIPTION_REMOVED", + "TYPE_DESCRIPTION_ADDED": "TYPE_DESCRIPTION_ADDED", + "UNION_MEMBER_REMOVED": "UNION_MEMBER_REMOVED", + "UNION_MEMBER_ADDED": "UNION_MEMBER_ADDED" + } + }, + "target_type": { + "name": "target_type", + "values": { + "federated": "federated", + "subgraph": "subgraph", + "graph": "graph" + } + } + }, + "schemas": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/controlplane/migrations/meta/_journal.json b/controlplane/migrations/meta/_journal.json index 8d0b50ae87..573e6c563a 100644 --- a/controlplane/migrations/meta/_journal.json +++ b/controlplane/migrations/meta/_journal.json @@ -274,6 +274,20 @@ "when": 1692867741484, "tag": "0038_tidy_lightspeed", "breakpoints": true + }, + { + "idx": 39, + "version": "5", + "when": 1692953011934, + "tag": "0039_old_wrecking_crew", + "breakpoints": true + }, + { + "idx": 40, + "version": "5", + "when": 1692965187503, + "tag": "0040_charming_sunfire", + "breakpoints": true } ] } \ No newline at end of file diff --git a/controlplane/src/core/bufservices/PlatformService.ts b/controlplane/src/core/bufservices/PlatformService.ts index 076f465a56..654c110bb3 100644 --- a/controlplane/src/core/bufservices/PlatformService.ts +++ b/controlplane/src/core/bufservices/PlatformService.ts @@ -420,6 +420,7 @@ export default function (opts: RouterOptions): Partial { const insertedSchemaCheck = await this.db .insert(schemaChecks) @@ -20,6 +21,7 @@ export class SchemaCheckRepository { targetId: data.targetId, isComposable: data.isComposable, proposedSubgraphSchemaSDL: data.proposedSubgraphSchemaSDL, + ...(data.schemaVersionId ? { schemaVersionId: data.schemaVersionId } : {}), }) .returning() .execute(); diff --git a/controlplane/src/core/repositories/SubgraphRepository.ts b/controlplane/src/core/repositories/SubgraphRepository.ts index cb35445cbd..45084c8ee1 100644 --- a/controlplane/src/core/repositories/SubgraphRepository.ts +++ b/controlplane/src/core/repositories/SubgraphRepository.ts @@ -178,6 +178,7 @@ export class SubgraphRepository { lastUpdatedAt: insertedVersion[0].createdAt.toISOString() ?? '', name: subgraphName, labels: subgraph.labels, + subgraphVersionId: subgraph.subgraphVersionId, }; }); } @@ -291,11 +292,13 @@ export class SubgraphRepository { let lastUpdatedAt = ''; let schemaSDL = ''; + let subgraphVersionId = ''; // Subgraphs are created without a schema version. if (resp.subgraph.schemaVersion !== null) { lastUpdatedAt = resp.subgraph.schemaVersion.createdAt?.toISOString() ?? ''; schemaSDL = resp.subgraph.schemaVersion.schemaSDL ?? ''; + subgraphVersionId = resp.subgraph.schemaVersion.id; } return { @@ -306,6 +309,7 @@ export class SubgraphRepository { schemaSDL, lastUpdatedAt, labels: resp.labels?.map?.((l) => splitLabel(l)) ?? [], + subgraphVersionId, }; } @@ -329,6 +333,9 @@ export class SubgraphRepository { schema.schemaChecks.targetId, subgraphs.map(({ targetId }) => targetId), ), + with: { + schemaVersion: true, + }, }); return checkList.map((c) => ({ @@ -339,6 +346,9 @@ export class SubgraphRepository { isBreaking: c.hasBreakingChanges ?? false, isComposable: c.isComposable ?? false, proposedSubgraphSchemaSDL: c.proposedSubgraphSchemaSDL ?? undefined, + // TODO: Figure out why type fails + // @ts-ignore + originalSchemaSDL: c?.schemaVersion?.schemaSDL, })); } diff --git a/controlplane/src/db/schema.ts b/controlplane/src/db/schema.ts index a8b09ed3f2..e540641f5a 100644 --- a/controlplane/src/db/schema.ts +++ b/controlplane/src/db/schema.ts @@ -249,6 +249,7 @@ export const schemaVersionChangeActionRelations = relations(schemaVersionChangeA export const schemaVersionRelations = relations(schemaVersion, ({ many }) => ({ changes: many(schemaVersionChangeAction), + schemaChecks: many(schemaChecks), })); export const schemaChecks = pgTable('schema_checks', { @@ -262,8 +263,16 @@ export const schemaChecks = pgTable('schema_checks', { hasBreakingChanges: boolean('has_breaking_changes').default(false), proposedSubgraphSchemaSDL: text('proposed_subgraph_schema_sdl'), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), + schemaVersionId: uuid('schema_version_id').references(() => schemaVersion.id), }); +export const schemaChecksRelations = relations(schemaChecks, ({ one }) => ({ + schemaVersion: one(schemaVersion, { + fields: [schemaChecks.schemaVersionId], + references: [schemaVersion.id], + }), +})); + export const schemaCheckChangeAction = pgTable('schema_check_change_action', { id: uuid('id').primaryKey().defaultRandom(), schemaCheckId: uuid('schema_check_id') diff --git a/controlplane/src/types/index.ts b/controlplane/src/types/index.ts index 710c9011c8..1e73b45083 100644 --- a/controlplane/src/types/index.ts +++ b/controlplane/src/types/index.ts @@ -41,6 +41,7 @@ export interface SubgraphDTO { schemaSDL: string; lastUpdatedAt: string; labels: Label[]; + subgraphVersionId?: string; } export interface MigrationSubgraph { @@ -57,6 +58,7 @@ export interface SchemaCheckDTO { isComposable: boolean; isBreaking: boolean; proposedSubgraphSchemaSDL?: string; + originalSchemaSDL: string; } export interface SchemaCheckDetailsDTO { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e63bc094da..976065ec7b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -465,6 +465,9 @@ importers: date-fns-tz: specifier: ^2.0.0 version: 2.0.0(date-fns@2.30.0) + diff: + specifier: ^5.1.0 + version: 5.1.0 graphiql: specifier: ^2.4.7 version: 2.4.7(@codemirror/language@6.0.0)(@types/node@20.3.1)(@types/react@18.2.14)(graphql@15.8.0)(react-dom@18.2.0)(react-is@17.0.2)(react@18.2.0) @@ -538,6 +541,9 @@ importers: '@types/dagre': specifier: ^0.7.48 version: 0.7.48 + '@types/diff': + specifier: ^5.0.3 + version: 5.0.3 '@types/lodash': specifier: ^4.14.195 version: 4.14.195 @@ -4178,6 +4184,10 @@ packages: resolution: {integrity: sha512-rF3yXSwHIrDxEkN6edCE4TXknb5YSEpiXfLaspw1I08grC49ZFuAVGOQCmZGIuLUGoFgcqGlUFBL/XrpgYpQgw==} dev: true + /@types/diff@5.0.3: + resolution: {integrity: sha512-amrLbRqTU9bXMCc6uX0sWpxsQzRIo9z6MJPkH1pkez/qOxuqSZVuryJAWoBRq94CeG8JxY+VK4Le9HtjQR5T9A==} + dev: true + /@types/geojson@7946.0.10: resolution: {integrity: sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==} dev: false @@ -6044,6 +6054,11 @@ packages: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} + /diff@5.1.0: + resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} + engines: {node: '>=0.3.1'} + dev: false + /difflib@0.2.4: resolution: {integrity: sha512-9YVwmMb0wQHQNr5J9m6BSj6fk4pfGITGQOOs+D9Fl+INODWFOfvhIU1hNv6GgR1RBoC/9NJcwu77zShxV0kT7w==} dependencies: diff --git a/proto/wg/cosmo/platform/v1/platform.proto b/proto/wg/cosmo/platform/v1/platform.proto index a3ff0842ea..ed311cbb68 100644 --- a/proto/wg/cosmo/platform/v1/platform.proto +++ b/proto/wg/cosmo/platform/v1/platform.proto @@ -224,6 +224,7 @@ message SchemaCheck { bool isComposable = 5; bool isBreaking = 6; optional string proposedSubgraphSchemaSDL = 7; + string originalSchemaSDL = 8; } message GetChecksByFederatedGraphNameResponse { diff --git a/studio/package.json b/studio/package.json index 6cf2e77d40..578f9b79b8 100644 --- a/studio/package.json +++ b/studio/package.json @@ -59,6 +59,7 @@ "dagre": "^0.8.5", "date-fns": "^2.30.0", "date-fns-tz": "^2.0.0", + "diff": "^5.1.0", "graphiql": "^2.4.7", "lodash": "^4.17.21", "next": "13.4.19", @@ -88,6 +89,7 @@ "@tailwindcss/typography": "^0.5.9", "@types/canvas-confetti": "^1.6.0", "@types/dagre": "^0.7.48", + "@types/diff": "^5.0.3", "@types/lodash": "^4.14.195", "@types/node": "20.3.1", "@types/react": "18.2.14", diff --git a/studio/src/components/analytics/getColumnData.tsx b/studio/src/components/analytics/getColumnData.tsx index 3092543594..b9f704c085 100644 --- a/studio/src/components/analytics/getColumnData.tsx +++ b/studio/src/components/analytics/getColumnData.tsx @@ -11,7 +11,7 @@ import copy from "copy-to-clipboard"; import { formatInTimeZone } from "date-fns-tz"; import compact from "lodash/compact"; import React, { ReactNode } from "react"; -import { SchemaViewer } from "../schmea-viewer"; +import { SchemaViewer } from "../schema-viewer"; import { Button } from "../ui/button"; import { Dialog, diff --git a/studio/src/components/schmea-viewer.tsx b/studio/src/components/schema-viewer.tsx similarity index 83% rename from studio/src/components/schmea-viewer.tsx rename to studio/src/components/schema-viewer.tsx index 84da495801..42160bb98d 100644 --- a/studio/src/components/schmea-viewer.tsx +++ b/studio/src/components/schema-viewer.tsx @@ -59,9 +59,11 @@ export const SchemaViewerActions = ({ export const SchemaViewer = ({ sdl, disableLinking, + showDiff = false, }: { sdl: string; disableLinking?: boolean; + showDiff?: boolean; }) => { const router = useRouter(); const pathname = router.asPath.split("#")[0]; @@ -94,12 +96,27 @@ export const SchemaViewer = ({ const href = disableLinking ? "#" : pathname + `#${lineNo}`; + const lineType = line?.[0]?.content?.startsWith?.("- ") + ? "removed" + : line?.[0]?.content?.startsWith?.("+ ") + ? "added" + : ""; + return (
{ + const diff = Diff.diffLines(original, newString); + + let output = ""; + + diff.forEach(function (part) { + if (part.added) { + const changedLines = part.value.split("\n"); + if (!changedLines[changedLines.length - 1]) changedLines.pop(); + output += changedLines.map((each) => `+ ${each}\n`).join(""); + } else if (part.removed) { + const changedLines = part.value.split("\n"); + if (!changedLines[changedLines.length - 1]) changedLines.pop(); + output += changedLines.map((each) => `- ${each}\n`).join(""); + } else { + const changedLines = part.value.split("\n"); + if (!changedLines[changedLines.length - 1]) changedLines.pop(); + output += changedLines.map((each) => ` ${each}\n`).join(""); + } + }); + return output; +}; const Details = ({ id, graphName }: { id: string; graphName: string }) => { const { data, isLoading, error, refetch } = useQuery( @@ -151,7 +175,7 @@ const ProposedSchema = ({ Schema
- +
@@ -250,7 +274,12 @@ const ChecksPage: NextPageWithLayout = () => { subgraphName, timestamp, proposedSubgraphSchemaSDL, + originalSchemaSDL, }) => { + const output = generateDiff( + originalSchemaSDL, + proposedSubgraphSchemaSDL! + ); return ( @@ -269,7 +298,7 @@ const ChecksPage: NextPageWithLayout = () => { {proposedSubgraphSchemaSDL ? ( ) : ( diff --git a/studio/src/pages/[organizationSlug]/graph/[slug]/schema.tsx b/studio/src/pages/[organizationSlug]/graph/[slug]/schema.tsx index b876525811..276371826e 100644 --- a/studio/src/pages/[organizationSlug]/graph/[slug]/schema.tsx +++ b/studio/src/pages/[organizationSlug]/graph/[slug]/schema.tsx @@ -1,7 +1,7 @@ import { GraphContext, getGraphLayout } from "@/components/layout/graph-layout"; import { PageHeader } from "@/components/layout/head"; import { TitleLayout } from "@/components/layout/title-layout"; -import { SchemaViewer, SchemaViewerActions } from "@/components/schmea-viewer"; +import { SchemaViewer, SchemaViewerActions } from "@/components/schema-viewer"; import { Select, SelectContent,