saleor-dashboard/src/navigation/queries.ts

56 lines
1.2 KiB
TypeScript
Raw Normal View History

import {
menuDetailsFragment,
menuFragment
} from "@saleor/fragments/navigation";
import { pageInfoFragment } from "@saleor/fragments/pageInfo";
2019-12-17 17:13:56 +00:00
import makeQuery from "@saleor/hooks/makeQuery";
import gql from "graphql-tag";
import { TypedQuery } from "../queries";
2019-06-19 14:40:52 +00:00
import { MenuDetails, MenuDetailsVariables } from "./types/MenuDetails";
import { MenuList, MenuListVariables } from "./types/MenuList";
const menuList = gql`
${menuFragment}
${pageInfoFragment}
2019-12-17 17:13:56 +00:00
query MenuList(
$first: Int
$after: String
$last: Int
$before: String
$sort: MenuSortingInput
) {
menus(
first: $first
after: $after
before: $before
last: $last
sortBy: $sort
) {
2019-06-19 14:40:52 +00:00
edges {
node {
...MenuFragment
}
}
pageInfo {
...PageInfoFragment
}
}
}
`;
2019-12-17 17:13:56 +00:00
export const useMenuListQuery = makeQuery<MenuList, MenuListVariables>(
menuList
);
2019-06-19 14:40:52 +00:00
const menuDetails = gql`
${menuDetailsFragment}
query MenuDetails($id: ID!) {
menu(id: $id) {
...MenuDetailsFragment
}
}
`;
export const MenuDetailsQuery = TypedQuery<MenuDetails, MenuDetailsVariables>(
menuDetails
);