Add opcode and bodyshop query to main
This commit is contained in:
@@ -6,6 +6,13 @@ import ipcTypes from "../../util/ipcTypes.json";
|
||||
|
||||
const requestMiddleware: RequestMiddleware = async (request) => {
|
||||
const token = await getTokenFromRenderer();
|
||||
log.info(
|
||||
`%c[Graphql Request]%c${request.operationName}`,
|
||||
"color: red",
|
||||
"color: green",
|
||||
request
|
||||
);
|
||||
|
||||
return {
|
||||
...request,
|
||||
headers: { ...request.headers, Authorization: `Bearer ${token}` },
|
||||
|
||||
73
src/main/graphql/queries.ts
Normal file
73
src/main/graphql/queries.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import { parse, TypedQueryDocumentNode } from "graphql";
|
||||
import { gql } from "graphql-request";
|
||||
|
||||
// Define types for the query result and variables
|
||||
export interface ActiveBodyshopQueryResult {
|
||||
bodyshops: Array<{
|
||||
id: string;
|
||||
shopname: string;
|
||||
region_config: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
// No variables needed for this query
|
||||
interface ActiveBodyshopQueryVariables {}
|
||||
|
||||
// Transform the string query into a TypedQueryDocumentNode
|
||||
export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
|
||||
ActiveBodyshopQueryResult,
|
||||
ActiveBodyshopQueryVariables
|
||||
> = parse(gql`
|
||||
query QUERY_ACTIVE_BODYSHOP {
|
||||
bodyshops(where: { associations: { active: { _eq: true } } }) {
|
||||
id
|
||||
shopname
|
||||
region_config
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
export interface MasterdataQueryResult {
|
||||
masterdata: Array<{
|
||||
value: string;
|
||||
key: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface MasterdataQueryVariables {
|
||||
key: string;
|
||||
}
|
||||
|
||||
export const QUERY_MASTERDATA_TYPED: TypedQueryDocumentNode<
|
||||
MasterdataQueryResult,
|
||||
MasterdataQueryVariables
|
||||
> = parse(gql`
|
||||
query QUERY_MASTERDATA($key: String!) {
|
||||
masterdata(where: { key: { _eq: $key } }) {
|
||||
value
|
||||
key
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
export interface VehicleQueryResult {
|
||||
masterdata: Array<{
|
||||
value: string;
|
||||
key: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface VehicleQueryVariables {
|
||||
vin: string;
|
||||
}
|
||||
|
||||
export const QUERY_VEHICLE_BY_VIN_TYPED: TypedQueryDocumentNode<
|
||||
VehicleQueryResult,
|
||||
VehicleQueryVariables
|
||||
> = parse(gql`
|
||||
query QUERY_VEHICLE_BY_VIN($vin: String!) {
|
||||
vehicles(where: { v_vin: { _eq: $vin } }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`);
|
||||
Reference in New Issue
Block a user