Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "@@//frontend:pnpm-lock.yaml").
# This file should be checked into version control along with the pnpm-lock.yaml file.
frontend/package-lock.json=1050907894
frontend/package.json=-1287539742
frontend/package.json=-2118623145
frontend/patches/vite.patch=-1261363333
frontend/pnpm-lock.yaml=1245402688
43 changes: 0 additions & 43 deletions frontend/create-possible-types.js

This file was deleted.

5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"build": "vite build",
"preview": "vite preview",
"test": "vitest",
"generate": "graphql-codegen --config ./src/graphql/codegen.ts && ./scripts/grpc-client-gen.sh",
"generate": "npm run generate-graphql && npm run generate-grpc && npm run generate-possible-types",
"generate-graphql": "graphql-codegen --config ./src/graphql/codegen.ts",
"generate-grpc": "./tools/grpc-client-gen.sh",
"generate-possible-types": "node ./tools/create-possible-types.js",
"predev": "npm run generate"
},
"dependencies": {
Expand Down
7 changes: 3 additions & 4 deletions frontend/src/components/ApolloWrapper/possibleTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"ArtifactMetrics": [],
"ArtifactMetricsWhereInput": [],
"AuthenticatedUser": [],
"AuthenticatedUserConnection": [],
"AuthenticatedUserEdge": [],
"AuthenticatedUserWhereInput": [],
"BazelInvocation": [],
"BazelInvocationConnection": [],
Expand All @@ -35,7 +33,6 @@
"ConnectionMetadataWhereInput": [],
"Cursor": [],
"Duration": [],
"Float": [],
"GarbageMetrics": [],
"GarbageMetricsWhereInput": [],
"ID": [],
Expand Down Expand Up @@ -84,6 +81,7 @@
"TargetMetrics",
"TestResult",
"TestSummary",
"TestTarget",
"TimingMetrics"
],
"OrderDirection": [],
Expand All @@ -104,7 +102,6 @@
"TargetMetrics": [],
"TargetMetricsWhereInput": [],
"TargetWhereInput": [],
"TargetsOverview": [],
"TestResult": [],
"TestResultWhereInput": [],
"TestSummary": [],
Expand All @@ -113,6 +110,8 @@
"TestSummaryOrder": [],
"TestSummaryOrderField": [],
"TestSummaryWhereInput": [],
"TestTarget": [],
"TestTargetWhereInput": [],
"Time": [],
"TimingMetrics": [],
"TimingMetricsWhereInput": [],
Expand Down
36 changes: 36 additions & 0 deletions frontend/tools/create-possible-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'node:fs';
import path from 'node:path';
import { buildSchema } from 'graphql';

const schemaFiles = [
'../internal/graphql/schema/scalars.graphql',
'../internal/graphql/schema/ent.graphql',
'../internal/graphql/schema/custom.graphql'
];

const schemaString = schemaFiles
.map(file => fs.readFileSync(path.resolve(file), 'utf8'))
.join('\n');

const schema = buildSchema(schemaString);
const typeMap = schema.getTypeMap();

const possibleTypes = {};

for (const type of Object.values(typeMap)) {
possibleTypes[type.name] ??= [];
}

for (const type of Object.values(typeMap)) {
const interfaces = type.getInterfaces?.() ?? [];
for (const iface of interfaces) {
if (possibleTypes[iface.name] !== undefined) {
possibleTypes[iface.name].push(type.name);
};
}
}

fs.writeFileSync(
'./src/components/ApolloWrapper/possibleTypes.json',
JSON.stringify(possibleTypes, Object.keys(possibleTypes).sort(), 2)
);
File renamed without changes.
Loading