Closed leoloso closed 3 years ago
Provide directives for searching/replacing the content in the field:
@replace(from: fromStr, to: toStr)
@regexReplace(regex: regex, to: toStr)
These directives make it easy to replace content on the field, without modifying the behavior of the field.
In the post content, replace all URLs for www.mydomain.com using either http or no protocol, to use https:
www.mydomain.com
http
https
{ posts { content @regexReplace( regex: "^(http:\/\/)?www\.mydomain\.com(\/.*)?$" to: "https://www.mydomain.com$2" ) } }
And if the content in the DB is "<p>Click <a href="www.mydomain.com/blog/">here</a>.</p>", the response will be:
"<p>Click <a href="www.mydomain.com/blog/">here</a>.</p>"
{ "posts": [ { "content": "<p>Click <a href=\"https://www.mydomain.com/blog/\">here</a>.</p>" } ] }
Closed due to inability to get sponsors to fund this feature.
Feature Request
Provide directives for searching/replacing the content in the field:
@replace(from: fromStr, to: toStr)
@regexReplace(regex: regex, to: toStr)
Context
These directives make it easy to replace content on the field, without modifying the behavior of the field.
Examples
In the post content, replace all URLs for
www.mydomain.com
using eitherhttp
or no protocol, to usehttps
:And if the content in the DB is
"<p>Click <a href="www.mydomain.com/blog/">here</a>.</p>"
, the response will be: