Augment tags from text field in GraphQL/REST API

オープン
#7,041 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
graphql, laravel, php

調査の方向性

Start by reading the GraphQL and REST API entry points that serialize text fields, then compare their behavior with Antlers template rendering and how custom tags are evaluated. The issue does not name files or tests, so first locate those paths and check for existing coverage. Done means tag expressions in text fields are handled consistently in API responses, with tests covering the reported example.

索引モデルが issue の本文から書いたものです。

説明

api graphql headless
Bug description

I have a text field with this in

Random {{ custom:wrap text="nonsense" }} news in your inbox. Once a month.

and a custom tag set up like this:

<?php

namespace App\Tags;

use Statamic\Tags\Tags;

class Custom extends Tags
{
    /**
     * The {{ custom:wrap text="Title text" }} tag
     *
     * @return string|array
     */
    public function wrap()
    {
        $text = $this->params->get('text', null);
        $random_int = random_int(1, 7);
        $length_class = "sketch-short sketch-short--" . $random_int;

        if (strlen($text) > 8) {
            $random_int = random_int(1, 2);
            $length_class = "sketch-long sketch-long--" . $random_int;
        }

        return '<span class="sketch ' . $length_class . '">' . $text . '</span>';
    }
}

When outputting the value in an antlers template it gets evaluated, but in the REST API or GraphQL it just returns the plain string.

Could a custom GraphQL middleware solve this?

How to reproduce
  • Set up custom Tag
  • use tag in regular text field
  • query with graphql or rest api
Logs

No response

Environment
Environment
Application Name: Statamic
Laravel Version: 9.39.0
PHP Version: 8.1.11
Composer Version: 2.4.3
Environment: local
Debug Mode: ENABLED
URL: asdf.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: regex
Version: 3.3.54 PRO
Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

主要言語
PHP
スター
4.9k
フォーク
647
平均マージ
1日 45分
マージ済み PR(30日)
221

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

statamic/cms のほかの issue

statamic/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。