Answers.Body: <p>So unfortunately, the short answer is that you can't. When you switch to using something else as the frontend for a Craft site (as opposed to Twig) you lose things like the Twig filter <code>typogrify</code>.</p>
  <p>While technically it might be possible to write a layer on top of GraphQL that did this for you via PHP, I'm not sure I'd recommend it.</p>
  <p>Instead, find JavaScript alternatives to the things you're used to in Twig.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-22T16:28:03.153Z
Answers.Text: Thank you, Andrew.
  
  We don't have much experience with implementing plugins in CraftCMS yet, but if possible, we will try to create a plugin that would allow you to set whether Typogrify should be applied to the GraphQL scheme.
  
  If this is set, the plugin will capture the output JSON of all GraphQL responses, recursively loop through it, and apply Typogrify for all text items.
  
  For performance reasons, there will eventually be the possibility to somehow configure the names of the keys in JSON, or something similar to XPath, to which Typogrify should possibly be applied. Just first ideas.
Answers.UserDisplayName: jan.reges
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-18T20:22:21.000Z
Answers.LastActivityDate: 2022-09-18T20:22:21.000Z
Answers.UserDisplayName: andrew.welch
Body: <p>we love CraftCMS and also typogrify plugin with Twig filter &quot;|typogrify&quot;.</p>
  <p>Now we are starting a web project that will combine Astro and CraftCMS will be used headless with the use of GraphQL API, which is very useful and excellently designed. We use latest CraftCMS 4.2.3 (PRO).</p>
  <p>What we currently lack compared to Twig is the ability to use |typogrify. Do you know some way to ensure that we apply server-side typogrify to text values coming from GraphQL?</p>
  <p>I know - correctly, the technology rendering the pages should take care of the typographical rules (so in our case Astro), but we have not yet found such a handy library as Typogrify.</p>
  <p>Thanks for any suggestions on how to solve this problem in a clean way :)</p>
  
Tags: <graphql><headless><api><plugin-typogrify>
Title: GraphQL fields with applied typogrify - any suggestions?
ThreadText: # GraphQL fields with applied typogrify - any suggestions?
  
  (Asked by: username_0 on 2022-09-05)
  
  we love CraftCMS and also typogrify plugin with Twig filter "|typogrify".
  
  Now we are starting a web project that will combine Astro and CraftCMS will be used headless with the use of GraphQL API, which is very useful and excellently designed. We use latest CraftCMS 4.2.3 (PRO).
  
  What we currently lack compared to Twig is the ability to use |typogrify. Do you know some way to ensure that we apply server-side typogrify to text values coming from GraphQL?
  
  I know - correctly, the technology rendering the pages should take care of the typographical rules (so in our case Astro), but we have not yet found such a handy library as Typogrify.
  
  Thanks for any suggestions on how to solve this problem in a clean way :)
  
  **Tags:** graphql, headless, api, plugin-typogrify
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-18. Score: 1
  
  So unfortunately, the short answer is that you can't. When you switch to using something else as the frontend for a Craft site (as opposed to Twig) you lose things like the Twig filter `typogrify`.
  
  While technically it might be possible to write a layer on top of GraphQL that did this for you via PHP, I'm not sure I'd recommend it.
  
  Instead, find JavaScript alternatives to the things you're used to in Twig.
  
  > **Comments:**
  > **username_0**: Thank you, Andrew.  We don't have much experience with implementing plugins in CraftCMS yet, but if possible, we will try to create a plugin that would allow you to set whether Typogrify should be applied to the GraphQL scheme.  If this is set, the plugin will capture the output JSON of all GraphQL responses, recursively loop through it, and apply Typogrify for all text items.  For performance reasons, there will eventually be the possibility to somehow configure the names of the keys in JSON, or something similar to XPath, to which Typogrify should possibly be applied. Just first ideas.  
  
  ---
  
  