From e900f2e1dfcdbdd42b336743cc0e3df3281374fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dro=C5=84?= Date: Thu, 1 Dec 2022 14:42:18 +0100 Subject: [PATCH] Fix strict null checks in webhooks (#2678) * Fix strict null errors in webhooks * Disable strict null checks * Update snapshots * Add migration comment in tsconfig * Fix 404 on loading * Fix loading case --- src/fragments/webhooks.ts | 14 +- src/graphql/hooks.generated.ts | 32 +- src/graphql/types.generated.ts | 6 +- .../__snapshots__/Stories.test.ts.snap | 1118 +++++------------ src/types.ts | 2 +- src/utils/urls.ts | 2 +- .../WebhookDeleteDialog.stories.tsx | 4 +- .../WebhookDeleteDialog.tsx | 7 +- .../WebhookDetailsPage.stories.tsx | 3 - .../WebhookDetailsPage/WebhookDetailsPage.tsx | 4 +- .../WebhooksDetailsPage.tsx | 12 +- .../components/WebhooksList/WebhooksList.tsx | 4 +- src/webhooks/fixtures.ts | 4 +- src/webhooks/mutations.ts | 4 +- src/webhooks/queries.ts | 10 +- src/webhooks/utils.tsx | 4 +- src/webhooks/views/WebhooksCreate.tsx | 9 +- src/webhooks/views/WebhooksDetails.tsx | 17 +- tsconfig.json | 3 + 19 files changed, 385 insertions(+), 874 deletions(-) diff --git a/src/fragments/webhooks.ts b/src/fragments/webhooks.ts index d004644b1..12f879315 100644 --- a/src/fragments/webhooks.ts +++ b/src/fragments/webhooks.ts @@ -1,6 +1,6 @@ import { gql } from "@apollo/client"; -export const webhooksFragment = gql` +export const webhookFragment = gql` fragment Webhook on Webhook { id name @@ -12,8 +12,16 @@ export const webhooksFragment = gql` } `; -export const webhooksDetailsFragment = gql` - fragment WebhooksDetails on Webhook { +export const webhookDetailsFragment = gql` + fragment WebhookDetails on Webhook { ...Webhook + syncEvents { + eventType + } + asyncEvents { + eventType + } + secretKey + targetUrl } `; diff --git a/src/graphql/hooks.generated.ts b/src/graphql/hooks.generated.ts index 2f0d1d0e4..6c326b03c 100644 --- a/src/graphql/hooks.generated.ts +++ b/src/graphql/hooks.generated.ts @@ -2784,9 +2784,17 @@ export const WarehouseDetailsFragmentDoc = gql` } ${WarehouseWithShippingFragmentDoc} ${AddressFragmentDoc}`; -export const WebhooksDetailsFragmentDoc = gql` - fragment WebhooksDetails on Webhook { +export const WebhookDetailsFragmentDoc = gql` + fragment WebhookDetails on Webhook { ...Webhook + syncEvents { + eventType + } + asyncEvents { + eventType + } + secretKey + targetUrl } ${WebhookFragmentDoc}`; export const AppCreateDocument = gql` @@ -16970,12 +16978,12 @@ export const WebhookCreateDocument = gql` ...WebhookError } webhook { - ...WebhooksDetails + ...WebhookDetails } } } ${WebhookErrorFragmentDoc} -${WebhooksDetailsFragmentDoc}`; +${WebhookDetailsFragmentDoc}`; export type WebhookCreateMutationFn = Apollo.MutationFunction; /** @@ -17009,12 +17017,12 @@ export const WebhookUpdateDocument = gql` ...WebhookError } webhook { - ...WebhooksDetails + ...WebhookDetails } } } ${WebhookErrorFragmentDoc} -${WebhooksDetailsFragmentDoc}`; +${WebhookDetailsFragmentDoc}`; export type WebhookUpdateMutationFn = Apollo.MutationFunction; /** @@ -17080,18 +17088,10 @@ export type WebhookDeleteMutationOptions = Apollo.BaseMutationOptions, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } }; export type WeightFragment = { __typename: 'Weight', unit: WeightUnitsEnum, value: number }; @@ -9410,7 +9410,7 @@ export type WebhookCreateMutationVariables = Exact<{ }>; -export type WebhookCreateMutation = { __typename: 'Mutation', webhookCreate: { __typename: 'WebhookCreate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', id: string, name: string, isActive: boolean, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; +export type WebhookCreateMutation = { __typename: 'Mutation', webhookCreate: { __typename: 'WebhookCreate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, id: string, name: string, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; export type WebhookUpdateMutationVariables = Exact<{ id: Scalars['ID']; @@ -9418,7 +9418,7 @@ export type WebhookUpdateMutationVariables = Exact<{ }>; -export type WebhookUpdateMutation = { __typename: 'Mutation', webhookUpdate: { __typename: 'WebhookUpdate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', id: string, name: string, isActive: boolean, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; +export type WebhookUpdateMutation = { __typename: 'Mutation', webhookUpdate: { __typename: 'WebhookUpdate', errors: Array<{ __typename: 'WebhookError', code: WebhookErrorCode, field: string | null, message: string | null }>, webhook: { __typename: 'Webhook', secretKey: string | null, targetUrl: string, id: string, name: string, isActive: boolean, syncEvents: Array<{ __typename: 'WebhookEventSync', eventType: WebhookEventTypeSyncEnum }>, asyncEvents: Array<{ __typename: 'WebhookEventAsync', eventType: WebhookEventTypeAsyncEnum }>, app: { __typename: 'App', id: string, name: string | null } } | null } | null }; export type WebhookDeleteMutationVariables = Exact<{ id: Scalars['ID']; diff --git a/src/storybook/__snapshots__/Stories.test.ts.snap b/src/storybook/__snapshots__/Stories.test.ts.snap index 66c1d7a00..60236631a 100644 --- a/src/storybook/__snapshots__/Stories.test.ts.snap +++ b/src/storybook/__snapshots__/Stories.test.ts.snap @@ -3550,7 +3550,7 @@ exports[`Storyshots Generics / AddressEdit default 1`] = `