Add gcmConsentTypes to GraphQL schema and resolvers
Expose gcmConsentTypes on CookieCategory type and accept it in UpdateCookieCategoryInput so the console can read and write GCM consent type mappings per category. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -458,6 +458,11 @@ func (r *mutationResolver) UpdateCookieCategory(ctx context.Context, input types
|
||||
|
||||
scope := coredata.NewScopeFromObjectID(input.CookieCategoryID)
|
||||
|
||||
var gcmConsentTypes *[]string
|
||||
if input.GcmConsentTypes != nil {
|
||||
gcmConsentTypes = &input.GcmConsentTypes
|
||||
}
|
||||
|
||||
category, err := r.cookieBanner.UpdateCookieCategory(
|
||||
ctx,
|
||||
scope,
|
||||
@@ -466,6 +471,7 @@ func (r *mutationResolver) UpdateCookieCategory(ctx context.Context, input types
|
||||
Name: input.Name,
|
||||
Slug: input.Slug,
|
||||
Description: input.Description,
|
||||
GCMConsentTypes: gcmConsentTypes,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
@@ -123,6 +123,7 @@ type CookieCategory implements Node {
|
||||
description: String!
|
||||
kind: CookieCategoryKind!
|
||||
rank: Int!
|
||||
gcmConsentTypes: [String!]!
|
||||
|
||||
cookies(
|
||||
first: Int
|
||||
@@ -308,6 +309,7 @@ input UpdateCookieCategoryInput {
|
||||
name: String
|
||||
slug: String
|
||||
description: String
|
||||
gcmConsentTypes: [String!]
|
||||
}
|
||||
|
||||
input DeleteCookieCategoryInput {
|
||||
|
||||
@@ -61,17 +61,22 @@ func NewCookieCategoryEdge(c *coredata.CookieCategory, orderBy coredata.CookieCa
|
||||
}
|
||||
|
||||
func NewCookieCategory(c *coredata.CookieCategory) *CookieCategory {
|
||||
gcmConsentTypes := c.GCMConsentTypes
|
||||
if gcmConsentTypes == nil {
|
||||
gcmConsentTypes = []string{}
|
||||
}
|
||||
return &CookieCategory{
|
||||
ID: c.ID,
|
||||
CookieBanner: &CookieBanner{
|
||||
ID: c.CookieBannerID,
|
||||
},
|
||||
Name: c.Name,
|
||||
Slug: c.Slug,
|
||||
Description: c.Description,
|
||||
Kind: c.Kind,
|
||||
Rank: c.Rank,
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
Name: c.Name,
|
||||
Slug: c.Slug,
|
||||
Description: c.Description,
|
||||
Kind: c.Kind,
|
||||
Rank: c.Rank,
|
||||
GcmConsentTypes: gcmConsentTypes,
|
||||
CreatedAt: c.CreatedAt,
|
||||
UpdatedAt: c.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user