Skip to content

Commit 11a922a

Browse files
committed
TECH-2041: introduced variables to graphql query
1 parent 2ae732d commit 11a922a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/client/WorkspaceNavigation.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ const hasPermission = async (gqlUrl, permission, path) => {
1111
accept: 'application/json'
1212
},
1313
body: JSON.stringify({
14-
query: `query {
14+
query: /* GraphQL */ `query ($path: String!, $permission: String!) {
1515
jcr {
16-
nodeByPath(path: "${path}") {
16+
nodeByPath(path: $path) {
1717
site {
18-
hasPermission(permissionName: "${permission}")
18+
hasPermission(permissionName: $permission)
1919
}
2020
}
2121
}
22-
}`})
22+
}`,
23+
variables: {path, permission}
24+
})
2325
});
2426

2527
const data = await response.json();
@@ -33,12 +35,12 @@ const WorkspaceNavigation = ({urls, mode, nodePath}) => {
3335

3436
useEffect(() => {
3537
const getPermissions = async () => {
36-
setHasJContentPermission(await hasPermission(urls.gqlUrl ,'jContentAccess', nodePath));
38+
setHasJContentPermission(await hasPermission(urls.gqlUrl, 'jContentAccess', nodePath));
3739
setIsLoading(false);
3840
};
3941

4042
getPermissions();
41-
}, []);
43+
}, [nodePath, urls.gqlUrl]);
4244

4345
if (isLoading) {
4446
return null;

0 commit comments

Comments
 (0)