Skip to content

Commit 58ebc64

Browse files
authored
Merge pull request #17 from gwu-libraries/fix-refetch-query
Temp fix (page refresh) to reloading, need to set up subscriptions
2 parents d08339d + 0282f91 commit 58ebc64

File tree

6 files changed

+60
-21
lines changed

6 files changed

+60
-21
lines changed

react/src/components/SideBar.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ function SideBar() {
3131
doi: doiSearch,
3232
investigationId: investigationId,
3333
},
34-
onCompleted: (data) => {},
34+
onCompleted: (data) => {
35+
{
36+
{
37+
window.location.reload();
38+
}
39+
}
40+
},
3541
onError: (data) => {
3642
console.log(data);
3743
},
38-
refetchQueries: [USE_INVESTIGATION_GRAPH],
44+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
3945
});
4046

4147
let doiInputHandler = (e) => {
@@ -55,11 +61,17 @@ function SideBar() {
5561
bodyText: noteBodyText,
5662
investigationId: investigationId,
5763
},
58-
onCompleted: (data) => {},
64+
onCompleted: (data) => {
65+
{
66+
{
67+
window.location.reload();
68+
}
69+
}
70+
},
5971
onError: (data) => {
6072
console.log(data);
6173
},
62-
refetchQueries: [USE_INVESTIGATION_GRAPH],
74+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
6375
});
6476

6577
return (
@@ -82,12 +94,12 @@ function SideBar() {
8294
></input>
8395
<button onClick={() => addAuthor()}>Add Author</button> */}
8496

85-
<input
97+
{/* <input
8698
className="border-4 border-solid border-red-500"
8799
value={noteBodyText}
88100
onChange={noteTextInputHandler}
89101
></input>
90-
<button onClick={() => addNote()}>Add Sticky Note</button>
102+
<button onClick={() => addNote()}>Add Sticky Note</button> */}
91103
</>
92104
);
93105
}

react/src/components/graph/InvestigationGraph.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ function InvestigationGraph({
3131
[]
3232
);
3333

34-
3534
const initialNodes = [];
3635
const initialEdges = [];
3736

@@ -70,20 +69,21 @@ function InvestigationGraph({
7069
for (let i = 0; i <= workEdges.length - 1; i++) {
7170
if (workEdges[i].visible) {
7271
initialEdges.push({
73-
source: `work-${workEdges[i].citationNode.id}`,
74-
target: `work-${workEdges[i].referenceNode.id}`,
72+
target: `work-${workEdges[i].citationNode.id}`,
73+
source: `work-${workEdges[i].referenceNode.id}`,
7574
id: `workedge-${workEdges[i].id}`,
7675
label: "citation/reference",
7776
style: {
7877
strokeWidth: 2,
7978
stroke: "#FF0072",
8079
},
81-
markerStart: {
80+
markerEnd: {
8281
type: MarkerType.ArrowClosed,
8382
width: 20,
8483
height: 20,
8584
color: "#FF0072",
8685
},
86+
animated: true,
8787
});
8888
}
8989
}
@@ -114,7 +114,6 @@ function InvestigationGraph({
114114
edges={edges}
115115
onNodesChange={onNodesChange}
116116
onEdgesChange={onEdgesChange}
117-
// onConnect={onConnect}
118117
nodeTypes={nodeTypes}
119118
nodesDraggable={true}
120119
fitView

react/src/components/graph/nodes/AuthorNode.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ function AuthorNode({ data }) {
2525

2626
const [addAuthorWorks] = useMutation(ADD_AUTHOR_WORKS, {
2727
errorPolicy: "ignore",
28-
onCompleted: (data) => {},
28+
onCompleted: (data) => {
29+
{
30+
{
31+
window.location.reload();
32+
}
33+
}
34+
},
2935
onError: (data) => {
3036
console.log(data);
3137
},
32-
refetchQueries: [USE_INVESTIGATION_GRAPH],
38+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
3339
});
3440

3541
useEffect(() => {

react/src/components/graph/nodes/NoteNode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function NoteNode({
2626
investigationId: investigationId,
2727
noteNodeId: id
2828
},
29-
refetchQueries: [USE_INVESTIGATION_GRAPH] // this doesn't seem to work for trigger refresh of graph, not sure why? It works in root node
29+
// refetchQueries: [USE_INVESTIGATION_GRAPH] // this doesn't seem to work for trigger refresh of graph, not sure why? It works in root node
3030
})
3131

3232
return (

react/src/components/graph/nodes/WorkDetails.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ function WorkDetails({
3333
const { investigationId } = useParams();
3434
const [addAuthor] = useMutation(CREATE_AUTHOR_NODE, {
3535
errorPolicy: "ignore",
36-
onCompleted: (data) => {},
36+
onCompleted: (data) => {
37+
{
38+
{
39+
window.location.reload();
40+
}
41+
}
42+
},
3743
onError: (data) => {
3844
console.log(data);
3945
},
40-
refetchQueries: [USE_INVESTIGATION_GRAPH],
46+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
4147
});
4248

4349
return (
@@ -50,7 +56,9 @@ function WorkDetails({
5056
>
5157
<tr className="border border-slate-700">
5258
<td
53-
colSpan={Math.max(authors.length, keywords.length, topics.length) + 1}
59+
colSpan={
60+
Math.max(authors.length, keywords.length, topics.length) + 1
61+
}
5462
>
5563
{abstract}
5664
</td>

react/src/components/graph/nodes/WorkNode.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,29 @@ function WorkNode({ data }) {
5757
openalexId: data.workData.work.openalexId,
5858
investigationId: investigationId,
5959
},
60-
refetchQueries: [USE_INVESTIGATION_GRAPH],
60+
onCompleted: (data) => {
61+
{
62+
{
63+
window.location.reload();
64+
}
65+
}
66+
},
67+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
6168
});
6269

6370
const [addCitations] = useMutation(ADD_CITATIONS, {
6471
variables: {
6572
openalexId: data.workData.work.openalexId,
6673
investigationId: investigationId,
6774
},
68-
refetchQueries: [USE_INVESTIGATION_GRAPH],
75+
onCompleted: (data) => {
76+
{
77+
{
78+
window.location.reload();
79+
}
80+
}
81+
},
82+
// refetchQueries: [USE_INVESTIGATION_GRAPH],
6983
});
7084

7185
useEffect(() => {
@@ -84,8 +98,8 @@ function WorkNode({ data }) {
8498
}}
8599
ref={noderef}
86100
>
87-
<Handle type="source" position={Position.Top} id="top-handle" />
88-
<Handle type="target" position={Position.Bottom} id="bottom-handle" />
101+
<Handle type="target" position={Position.Top} id="top-handle" />
102+
<Handle type="source" position={Position.Bottom} id="bottom-handle" />
89103
<label htmlFor="text">{data.workData.work.title}</label>
90104
<button onClick={() => addReferences()}>Show References</button>
91105
<p></p>

0 commit comments

Comments
 (0)