Skip to content
Open
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 @@ -36,51 +36,49 @@ beforeEach(() => {
});

const mockExperiments = {
instrumentSession: {
experiments: {
edges: [
{
node: {
name: "Exp 1",
sample: {
name: "Sample A",
data: {
density: 1.2,
composition: "H2O",
},
experiments: {
edges: [
{
node: {
name: "Exp 1",
sample: {
name: "Sample A",
data: {
density: 1.2,
composition: "H2O",
},
experimentDefinition: {
name: "Def 1",
data: {
beam_energy: 20,
time_per_pdf: 10,
focused_beam_size: 5,
},
},
experimentDefinition: {
name: "Def 1",
data: {
beam_energy: 20,
time_per_pdf: 10,
focused_beam_size: 5,
},
},
},
{
node: {
name: "Exp 2",
sample: {
name: "Sample B",
data: {
density: 1.2,
composition: "CO2",
},
},
{
node: {
name: "Exp 2",
sample: {
name: "Sample B",
data: {
density: 1.2,
composition: "CO2",
},
experimentDefinition: {
name: "Def 2",
data: {
beam_energy: 20,
time_per_pdf: 10,
focused_beam_size: 5,
},
},
experimentDefinition: {
name: "Def 2",
data: {
beam_energy: 20,
time_per_pdf: 10,
focused_beam_size: 5,
},
},
},
],
},
},
],
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function ExperimentList() {
context: { pathname: location.pathname },
});

const experiments = data?.instrumentSession?.experiments.edges || [];
const experiments = data?.experiments?.edges || [];

const typedExperiments = experiments as {
node: ExperimentNode<SampleData, ExperimentDefinitionData>;
Expand Down
49 changes: 23 additions & 26 deletions apps/i15-1/src/graphql/getSessionPlaylistQuery.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@ export type GetSessionPlaylistQueryVariables = Exact<{
}>;

export type GetSessionPlaylistQuery = {
instrumentSession: {
__typename: "InstrumentSession";
experiments: {
__typename: "ExperimentConnection";
edges: Array<{
__typename: "ExperimentEdge";
node: {
__typename: "Experiment";
experiments: {
__typename: "ExperimentConnection";
edges: Array<{
__typename: "ExperimentEdge";
node: {
__typename: "Experiment";
name: string;
sample: {
__typename: "Sample";
name: string;
sample: {
__typename: "Sample";
name: string;
id: unknown;
data: unknown;
instrumentSessions: Array<{
__typename: "InstrumentSession";
instrumentSessionReference: string | null;
}>;
};
experimentDefinition: {
__typename: "ExperimentDefinition";
name: string;
id: unknown;
data: unknown;
};
id: unknown;
data: unknown;
instrumentSessions: Array<{
__typename: "InstrumentSession";
instrumentSessionReference: string | null;
}>;
};
}>;
};
experimentDefinition: {
__typename: "ExperimentDefinition";
name: string;
id: unknown;
data: unknown;
};
};
}>;
} | null;
};
40 changes: 20 additions & 20 deletions apps/i15-1/src/graphql/getSessionPlaylistQuery.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { gql } from "@apollo/client";

export const getSessionPlaylistQuery = gql`
query GetSessionPlaylist($proposal: Int!, $session: Int!) {
instrumentSession(
query GetSessionPlaylist($proposal: Int!, $session: Int!) {
experiments(
instrumentSessions: {
proposalNumber: $proposal
instrumentSessionNumber: $session
) {
experiments {
edges {
node {
name
sample {
name
id
instrumentSessions {
instrumentSessionReference
}
data
}
experimentDefinition {
name
id
data
}
}
) {
edges {
node {
name
sample {
name
id
data
instrumentSessions {
instrumentSessionReference
}
}
experimentDefinition {
name
id
data
}
}
}
}
}
`;
4 changes: 2 additions & 2 deletions apps/i15-1/src/graphql/getSessionPlaylistQueryTyped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ You can use the `ExperimentNode` type to enforce this.
*/

type GeneratedNode = NonNullable<
GetSessionPlaylistQuery["instrumentSession"]
>["experiments"]["edges"][number]["node"];
GetSessionPlaylistQuery["experiments"]
>["edges"][number]["node"];

type WithTypedData<
TNode extends {
Expand Down
112 changes: 55 additions & 57 deletions apps/i15-1/src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,73 +8,71 @@ const workerStatus = { status: "IDLE", duration: 0 };

const fakeExperiments = {
data: {
instrumentSession: {
experiments: {
edges: [
{
node: {
name: "Test experiment",
sample: {
name: "Test_8_1",
id: "a47cd8af-03f4-430b-9858-749c61f6e14c",
instrumentSessions: [
{
instrumentSessionReference: "CM44163-3",
},
],
data: {
density: 56,
capillary: "bs1.5",
composition: "Stuff",
packing_fraction: 0.5,
experiments: {
edges: [
{
node: {
name: "Test experiment",
sample: {
name: "Test_8_1",
id: "a47cd8af-03f4-430b-9858-749c61f6e14c",
instrumentSessions: [
{
instrumentSessionReference: "CM44163-3",
},
],
data: {
density: 56,
capillary: "bs1.5",
composition: "Stuff",
packing_fraction: 0.5,
},
experimentDefinition: {
name: "run_full_collection",
id: "62b75b2f-8401-4230-b7ef-a4e577af598a",
data: {
q_max: 67,
frames: 90,
beam_energy: 40,
time_per_pdf: 2,
focused_beam_size: 10,
},
},
experimentDefinition: {
name: "run_full_collection",
id: "62b75b2f-8401-4230-b7ef-a4e577af598a",
data: {
q_max: 67,
frames: 90,
beam_energy: 40,
time_per_pdf: 2,
focused_beam_size: 10,
},
},
},
{
node: {
name: "Test experiment 2",
sample: {
name: "Test_8_2",
id: "19ad91f0-a155-4c5c-b5ba-175bb6f7c057",
instrumentSessions: [
{
instrumentSessionReference: "CM44163-3",
},
],
data: {
density: 56,
capillary: "bs1.5",
composition: "Stuff",
packing_fraction: 0.5,
},
{
node: {
name: "Test experiment 2",
sample: {
name: "Test_8_2",
id: "19ad91f0-a155-4c5c-b5ba-175bb6f7c057",
instrumentSessions: [
{
instrumentSessionReference: "CM44163-3",
},
],
data: {
density: 56,
capillary: "bs1.5",
composition: "Stuff",
packing_fraction: 0.5,
},
experimentDefinition: {
name: "run_full_collection",
id: "b645e887-85b4-40d6-a8f0-500a436bc395",
data: {
q_max: 67,
frames: 100,
beam_energy: 40,
time_per_pdf: 2,
focused_beam_size: 3,
},
},
experimentDefinition: {
name: "run_full_collection",
id: "b645e887-85b4-40d6-a8f0-500a436bc395",
data: {
q_max: 67,
frames: 100,
beam_energy: 40,
time_per_pdf: 2,
focused_beam_size: 3,
},
},
},
],
},
},
],
},
},
};
Expand Down
Loading