Migrate detection page to TrackerPattern GraphQL types
- Add TrackerPattern type, connection, and filter to GraphQL schema - Add uncategorisedTrackerPatterns field on CookieBanner - Add updateTrackerPattern, deleteTrackerPattern, moveTrackerPatternToCategory mutations - Implement all resolvers backed by tracker_patterns table - Add TrackerPattern service methods (CRUD + list/count) - Add LoadUncategorisedByCookieBannerID on TrackerPatterns coredata - Update detection page to use TrackerPattern fragment, queries, and mutations - CookieCategory resolver uses dataloader (not just struct ID) Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -58,14 +58,14 @@ const detectionFragment = graphql`
|
||||
@refetchable(queryName: "CookieBannerDetectionPageRefetchQuery")
|
||||
@argumentDefinitions(
|
||||
first: { type: "Int", defaultValue: 50 }
|
||||
order: { type: "CookiePatternOrder", defaultValue: { field: NAME, direction: ASC } }
|
||||
order: { type: "TrackerPatternOrder", defaultValue: { field: NAME, direction: ASC } }
|
||||
after: { type: "CursorKey", defaultValue: null }
|
||||
before: { type: "CursorKey", defaultValue: null }
|
||||
last: { type: "Int", defaultValue: null }
|
||||
query: { type: "String", defaultValue: null }
|
||||
source: { type: "CookieSource", defaultValue: null }
|
||||
) {
|
||||
uncategorisedPatterns(
|
||||
uncategorisedTrackerPatterns(
|
||||
first: $first
|
||||
after: $after
|
||||
last: $last
|
||||
@@ -74,7 +74,7 @@ const detectionFragment = graphql`
|
||||
filter: { query: $query, source: $source }
|
||||
)
|
||||
@connection(
|
||||
key: "CookieBannerDetectionPage_uncategorisedPatterns"
|
||||
key: "CookieBannerDetectionPage_uncategorisedTrackerPatterns"
|
||||
filters: ["filter", "orderBy"]
|
||||
)
|
||||
@required(action: THROW) {
|
||||
@@ -112,8 +112,8 @@ export default function CookieBannerDetectionPage({
|
||||
CookieBannerDetectionPageFragment$key
|
||||
>(detectionFragment, data.node);
|
||||
|
||||
const connectionId = fragmentData.uncategorisedPatterns.__id;
|
||||
const patterns = fragmentData.uncategorisedPatterns.edges.map(edge => edge.node) ?? [];
|
||||
const connectionId = fragmentData.uncategorisedTrackerPatterns.__id;
|
||||
const patterns = fragmentData.uncategorisedTrackerPatterns.edges.map(edge => edge.node) ?? [];
|
||||
|
||||
const refetchFilters = (overrides: Record<string, unknown> = {}) => {
|
||||
startTransition(() => {
|
||||
|
||||
@@ -44,7 +44,7 @@ import {
|
||||
} from "./MoveToCategoryDropdown";
|
||||
|
||||
const detectionPatternFragment = graphql`
|
||||
fragment DetectionPatternRowFragment on CookiePattern {
|
||||
fragment DetectionPatternRowFragment on TrackerPattern {
|
||||
id
|
||||
trackerType
|
||||
displayName
|
||||
@@ -59,11 +59,11 @@ const detectionPatternFragment = graphql`
|
||||
|
||||
const deletePatternMutation = graphql`
|
||||
mutation DetectionPatternRowDeleteMutation(
|
||||
$input: DeleteCookiePatternInput!
|
||||
$input: DeleteTrackerPatternInput!
|
||||
$connections: [ID!]!
|
||||
) {
|
||||
deleteCookiePattern(input: $input) {
|
||||
deletedCookiePatternId @deleteEdge(connections: $connections)
|
||||
deleteTrackerPattern(input: $input) {
|
||||
deletedTrackerPatternId @deleteEdge(connections: $connections)
|
||||
cookieBanner {
|
||||
id
|
||||
latestVersion {
|
||||
@@ -78,10 +78,10 @@ const deletePatternMutation = graphql`
|
||||
|
||||
const movePatternMutation = graphql`
|
||||
mutation DetectionPatternRowMoveMutation(
|
||||
$input: MoveCookiePatternToCategoryInput!
|
||||
$input: MoveTrackerPatternToCategoryInput!
|
||||
) {
|
||||
moveCookiePatternToCategory(input: $input) {
|
||||
cookiePattern {
|
||||
moveTrackerPatternToCategory(input: $input) {
|
||||
trackerPattern {
|
||||
id
|
||||
cookieCategory {
|
||||
id
|
||||
@@ -101,10 +101,10 @@ const movePatternMutation = graphql`
|
||||
|
||||
const updatePatternMutation = graphql`
|
||||
mutation DetectionPatternRowUpdateMutation(
|
||||
$input: UpdateCookiePatternInput!
|
||||
$input: UpdateTrackerPatternInput!
|
||||
) {
|
||||
updateCookiePattern(input: $input) {
|
||||
cookiePattern {
|
||||
updateTrackerPattern(input: $input) {
|
||||
trackerPattern {
|
||||
id
|
||||
displayName
|
||||
maxAgeSeconds
|
||||
@@ -174,7 +174,7 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte
|
||||
new Promise<void>((resolve) => {
|
||||
deletePattern({
|
||||
variables: {
|
||||
input: { cookiePatternId: pattern.id },
|
||||
input: { trackerPatternId: pattern.id },
|
||||
connections: [connectionId],
|
||||
},
|
||||
onCompleted(_, errors) {
|
||||
@@ -203,13 +203,13 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte
|
||||
movePattern({
|
||||
variables: {
|
||||
input: {
|
||||
cookiePatternId: pattern.id,
|
||||
trackerPatternId: pattern.id,
|
||||
targetCookieCategoryId: targetCategoryId,
|
||||
},
|
||||
},
|
||||
updater(store) {
|
||||
const payload = store.getRootField("moveCookiePatternToCategory");
|
||||
if (!payload?.getLinkedRecord("cookiePattern")) {
|
||||
const payload = store.getRootField("moveTrackerPatternToCategory");
|
||||
if (!payload?.getLinkedRecord("trackerPattern")) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte
|
||||
updatePattern({
|
||||
variables: {
|
||||
input: {
|
||||
cookiePatternId: pattern.id,
|
||||
trackerPatternId: pattern.id,
|
||||
excluded: !pattern.excluded,
|
||||
},
|
||||
},
|
||||
@@ -255,7 +255,7 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte
|
||||
updatePattern({
|
||||
variables: {
|
||||
input: {
|
||||
cookiePatternId: pattern.id,
|
||||
trackerPatternId: pattern.id,
|
||||
displayName: data.displayName,
|
||||
description: data.description,
|
||||
maxAgeSeconds: data.maxAgeSeconds,
|
||||
|
||||
Reference in New Issue
Block a user