2022-02-21 13:32:38 +00:00
|
|
|
import { gql } from "@apollo/client";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { appFragment } from "@saleor/fragments/apps";
|
|
|
|
import { webhooksFragment } from "@saleor/fragments/webhooks";
|
|
|
|
import makeQuery from "@saleor/hooks/makeQuery";
|
|
|
|
|
|
|
|
import { App, AppVariables } from "./types/App";
|
|
|
|
import { AppsInstallations } from "./types/AppsInstallations";
|
|
|
|
import { AppsList, AppsListVariables } from "./types/AppsList";
|
2021-08-20 13:58:53 +00:00
|
|
|
import { ExtensionList, ExtensionListVariables } from "./types/ExtensionList";
|
2020-07-22 10:54:15 +00:00
|
|
|
|
|
|
|
const appsList = gql`
|
|
|
|
query AppsList(
|
|
|
|
$before: String
|
|
|
|
$after: String
|
|
|
|
$first: Int
|
|
|
|
$last: Int
|
|
|
|
$sort: AppSortingInput
|
|
|
|
$filter: AppFilterInput
|
|
|
|
) {
|
|
|
|
apps(
|
|
|
|
before: $before
|
|
|
|
after: $after
|
|
|
|
first: $first
|
|
|
|
last: $last
|
|
|
|
sortBy: $sort
|
|
|
|
filter: $filter
|
|
|
|
) {
|
|
|
|
pageInfo {
|
|
|
|
hasNextPage
|
|
|
|
hasPreviousPage
|
|
|
|
startCursor
|
|
|
|
endCursor
|
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
isActive
|
|
|
|
type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const appsInProgressList = gql`
|
|
|
|
query AppsInstallations {
|
|
|
|
appsInstallations {
|
|
|
|
status
|
|
|
|
message
|
|
|
|
appName
|
|
|
|
manifestUrl
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const appDetails = gql`
|
|
|
|
${appFragment}
|
|
|
|
${webhooksFragment}
|
|
|
|
query App($id: ID!) {
|
|
|
|
app(id: $id) {
|
|
|
|
...AppFragment
|
|
|
|
aboutApp
|
|
|
|
permissions {
|
|
|
|
code
|
|
|
|
name
|
|
|
|
}
|
|
|
|
dataPrivacy
|
|
|
|
dataPrivacyUrl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2021-08-20 13:58:53 +00:00
|
|
|
export const extensionList = gql`
|
|
|
|
query ExtensionList($filter: AppExtensionFilterInput!) {
|
2022-02-02 15:30:34 +00:00
|
|
|
appExtensions(filter: $filter, first: 100) {
|
2021-08-20 13:58:53 +00:00
|
|
|
edges {
|
|
|
|
node {
|
|
|
|
id
|
|
|
|
label
|
|
|
|
url
|
2022-02-02 15:30:34 +00:00
|
|
|
mount
|
2021-08-20 13:58:53 +00:00
|
|
|
target
|
|
|
|
accessToken
|
2022-02-02 15:30:34 +00:00
|
|
|
permissions {
|
|
|
|
code
|
|
|
|
}
|
|
|
|
app {
|
|
|
|
id
|
|
|
|
appUrl
|
|
|
|
}
|
2021-08-20 13:58:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-07-22 10:54:15 +00:00
|
|
|
export const useAppsListQuery = makeQuery<AppsList, AppsListVariables>(
|
|
|
|
appsList
|
|
|
|
);
|
|
|
|
|
|
|
|
export const useAppsInProgressListQuery = makeQuery<AppsInstallations, {}>(
|
|
|
|
appsInProgressList
|
|
|
|
);
|
|
|
|
|
|
|
|
export const useAppDetails = makeQuery<App, AppVariables>(appDetails);
|
2021-08-20 13:58:53 +00:00
|
|
|
|
|
|
|
export const useExtensionList = makeQuery<
|
|
|
|
ExtensionList,
|
|
|
|
ExtensionListVariables
|
|
|
|
>(extensionList);
|