Bricks
BricksBricks

Bricks

Bricks 플러그인과의 통합입니다.

GraphQL 스키마에는 페이지 및 템플릿에서 Bricks 데이터를 가져오고 업데이트하기 위한 필드와 뮤테이션이 제공됩니다.

필드

커스텀 포스트의 Bricks 데이터를 쿼리할 수 있습니다. 모든 CustomPost 타입(예: Post, Page, GenericCustomPost)에 추가된 다음 필드를 통해 조회합니다:

  • bricksData

또한, 루트 필드 bricksComponents를 통해 Bricks 컴포넌트를 쿼리할 수도 있습니다.

bricksData

필드 CustomPost.bricksData: [JSONObject!]는 Bricks가 저장한 형식으로 커스텀 포스트의 Bricks 데이터를 가져옵니다.

다음 쿼리를 실행하면:

{
  post(by: { id: 1 }) {
    bricksData
  }
}

...다음과 같은 응답이 반환될 수 있습니다:

{
  "data": {
    "post": {
      "bricksData": [
        {
          "id": "oleqdy",
          "name": "section",
          "parent": 0,
          "children": [
            "uuiyqj"
          ],
          "settings": []
        },
        {
          "id": "uuiyqj",
          "name": "container",
          "parent": "oleqdy",
          "children": [
            "ejfwpo",
            "czivwt",
            "ucuzdk",
            "wzcyug",
            "ipoorm",
            "zvgqxx",
            "yrambp",
            "hywkos",
            "gdoiqo",
            "tyksto",
            "nquple",
            "typize",
            "fjiwqp"
          ],
          "settings": []
        },
        {
          "id": "ejfwpo",
          "name": "post-title",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "tag": "h1"
          }
        },
        {
          "id": "czivwt",
          "name": "post-excerpt",
          "parent": "uuiyqj",
          "children": [],
          "settings": []
        },
        {
          "id": "hywkos",
          "name": "post-comments",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "title": true,
            "avatar": true,
            "formTitle": true,
            "label": true,
            "submitButtonStyle": "primary"
          }
        },
        {
          "id": "yrambp",
          "name": "post-author",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "avatar": true,
            "name": true,
            "website": true,
            "bio": true,
            "postsLink": true,
            "postsStyle": "primary"
          }
        },
        {
          "id": "zvgqxx",
          "name": "related-posts",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "taxonomies": [
              "category",
              "post_tag"
            ],
            "content": [
              {
                "dynamicData": "{post_title:link}",
                "tag": "h3",
                "dynamicMargin": {
                  "top": 10
                },
                "id": "a667d0"
              },
              {
                "dynamicData": "{post_date}",
                "id": "5bb1b2"
              },
              {
                "dynamicData": "{post_excerpt:20}",
                "dynamicMargin": {
                  "top": 10
                },
                "id": "80e288"
              }
            ]
          }
        }
      ]
    }
  }
}

includeexclude를 받는 파라미터 filterBy를 통해 이름으로 요소를 필터링할 수도 있습니다.

다음 쿼리를 실행하면:

{
  post(by: { id: 1 }) {
    bricksData(filterBy: {include: ["post-comments", "post-author"]})
  }
}

...다음과 같은 응답이 반환됩니다:

{
  "data": {
    "post": {
      "bricksData": [
        {
          "id": "hywkos",
          "name": "post-comments",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "title": true,
            "avatar": true,
            "formTitle": true,
            "label": true,
            "submitButtonStyle": "primary"
          }
        },
        {
          "id": "yrambp",
          "name": "post-author",
          "parent": "uuiyqj",
          "children": [],
          "settings": {
            "avatar": true,
            "name": true,
            "website": true,
            "bio": true,
            "postsLink": true,
            "postsStyle": "primary"
          }
        }
      ]
    }
  }
}

파라미터 replaceComponents: true를 전달하면 Bricks 전역 컴포넌트를 해당 Bricks 요소로 교체할 수 있습니다:

{
  post(by: { id: 1 }) {
    bricksData(replaceComponents: true)
  }
}

bricksComponents

필드 Root.bricksComponents: [JSONObject!]!는 Bricks가 옵션 bricks_components에 저장한 전역 컴포넌트의 Bricks 데이터를 가져옵니다.

다음 쿼리를 실행하면:

{
  bricksComponents
}

...다음과 같은 응답이 반환될 수 있습니다:

[
  {
    "id": "fufxfs",
    "category": "",
    "desc": "",
    "elements": [
      {
        "id": "fufxfs",
        "name": "container",
        "settings": {
          "_width": "50%",
          "_alignItems": "flex-start",
          "_padding": {
            "left": "",
            "right": 50
          },
          "_width:mobile_portrait": "100%",
          "_padding:tablet_portrait": {
            "right": "25"
          },
          "_padding:mobile_portrait": {
            "right": "0"
          },
          "_alignSelf": "center",
          "_order:mobile_portrait": "2",
          "_margin:mobile_portrait": {
            "top": "60"
          },
          "_flexShrink": "0"
        },
        "children": [
          "e8fab6",
          "52c06c"
        ],
        "parent": 0,
        "label": "Icons"
      },
      {
        "id": "e8fab6",
        "name": "icon-box",
        "settings": {
          "icon": {
            "library": "fontawesomeSolid",
            "icon": "fas fa-check-square"
          },
          "content": "<h4>Business Professionals<\/h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit aliquam.<\/p>",
          "textAlign": "left",
          "iconPosition": "left",
          "verticalAlign": "flex-start",
          "_padding": {
            "top": "20",
            "right": "20",
            "bottom": "20",
            "left": 20
          },
          "_background": {
            "color": {
              "hex": "#ffffff"
            }
          },
          "_border": {
            "width": {
              "top": "1",
              "right": "1",
              "bottom": "1",
              "left": "1"
            },
            "style": "solid",
            "radius": {
              "top": "10"
            },
            "color": {
              "hex": "#f2f2f2"
            }
          },
          "typographyHeading": {
            "font-size": "16px",
            "font-family": "Open Sans",
            "font-weight": "600",
            "color": {
              "hex": "#30354a"
            }
          },
          "iconColor": {
            "hex": "#ff57a2"
          },
          "iconSize": "20px",
          "contentMargin": {
            "top": 8
          },
          "_boxShadow": {
            "values": {
              "offsetX": "2",
              "offsetY": "2",
              "blur": "25"
            },
            "color": {
              "hex": "#000000",
              "rgb": "rgba(0, 0, 0, 0.11)",
              "hsl": "hsla(0, 0%, 0%, 0.11)"
            }
          },
          "typographyBody": {
            "color": {
              "hex": "#919191"
            },
            "font-size": "13px",
            "font-family": "Open Sans"
          },
          "iconPadding": {
            "top": "15",
            "right": "15",
            "bottom": "15",
            "left": "15"
          },
          "iconBackgroundColor": {
            "hex": "#ff57a2",
            "rgb": "rgba(255, 87, 162, 0.2)",
            "hsl": "hsla(333, 100%, 67%, 0.2)"
          },
          "iconBorder": {
            "radius": {
              "top": "100",
              "right": "100",
              "bottom": "100",
              "left": "100"
            }
          },
          "_boxShadow:hover": {
            "values": {
              "offsetX": "2",
              "offsetY": "2",
              "blur": "15"
            },
            "color": {
              "hex": "#000000",
              "rgb": "rgba(0, 0, 0, 0.2)",
              "hsl": "hsla(0, 0%, 0%, 0.2)"
            }
          }
        },
        "children": [],
        "parent": "fufxfs"
      },
      {
        "id": "52c06c",
        "name": "icon-box",
        "settings": {
          "icon": {
            "library": "fontawesomeSolid",
            "icon": "fas fa-check-square"
          },
          "content": "<h4>Cloud Services<\/h4><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit aliquam.<\/p>",
          "textAlign": "left",
          "iconPosition": "left",
          "verticalAlign": "flex-start",
          "_padding": {
            "top": "20",
            "right": "20",
            "bottom": "20",
            "left": 20
          },
          "_background": {
            "color": {
              "hex": "#ffffff"
            }
          },
          "_border": {
            "width": {
              "top": "1",
              "right": "1",
              "bottom": "1",
              "left": "1"
            },
            "style": "solid",
            "radius": {
              "top": "10"
            },
            "color": {
              "hex": "#f2f2f2"
            }
          },
          "typographyHeading": {
            "font-size": "16px",
            "font-family": "Open Sans",
            "font-weight": "600",
            "color": {
              "hex": "#30354a"
            },
            "line-height": "1none"
          },
          "iconColor": {
            "hex": "#3d30ba"
          },
          "iconSize": "20px",
          "contentMargin": {
            "top": 8
          },
          "_boxShadow": {
            "values": {
              "offsetX": "2",
              "offsetY": "2",
              "blur": "25"
            },
            "color": {
              "hex": "#000000",
              "rgb": "rgba(0, 0, 0, 0.11)",
              "hsl": "hsla(0, 0%, 0%, 0.11)"
            }
          },
          "typographyBody": {
            "color": {
              "hex": "#919191"
            },
            "font-size": "13px",
            "font-family": "Open Sans"
          },
          "iconPadding": {
            "top": "15",
            "right": "15",
            "bottom": "15",
            "left": "15"
          },
          "iconBackgroundColor": {
            "hex": "#3e30bb",
            "rgb": "rgba(62, 48, 187, 0.2)",
            "hsl": "hsla(246, 59%, 46%, 0.2)"
          },
          "iconBorder": {
            "radius": {
              "top": "100",
              "right": "100",
              "bottom": "100",
              "left": "100"
            }
          },
          "_margin": {
            "top": 30
          },
          "_boxShadow:hover": {
            "values": {
              "offsetX": "2",
              "offsetY": "2",
              "blur": "15"
            },
            "color": {
              "hex": "#000000",
              "rgb": "rgba(0, 0, 0, 0.2)",
              "hsl": "hsla(0, 0%, 0%, 0.2)"
            }
          }
        },
        "children": [],
        "parent": "fufxfs"
      }
    ],
    "properties": [],
    "_created": 1750156913,
    "_user_id": 1,
    "_version": "2.0-beta"
  }
]

뮤테이션

다음 뮤테이션을 사용하여 커스텀 포스트의 Bricks 데이터를 업데이트합니다:

bricksSetCustomPostElementData는 Bricks와 동일한 형식의 JSON을 받아 커스텀 포스트의 Bricks 데이터를 설정합니다.

bricksMergeCustomPostElementDataItem은 커스텀 포스트의 Bricks 데이터에서 특정 요소의 값을 덮어씁니다.

bricksRegenerateCustomPostElementIDSet은 커스텀 포스트의 Bricks 데이터에 있는 요소 ID를 재생성합니다.