Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ability to request velocity-rendered fields values in the GraphQL request #20407

Closed
dsilvam opened this issue May 18, 2021 · 4 comments · Fixed by #20397 or #20564
Closed

Introduce ability to request velocity-rendered fields values in the GraphQL request #20407

dsilvam opened this issue May 18, 2021 · 4 comments · Fixed by #20397 or #20564

Comments

@dsilvam
Copy link
Contributor

dsilvam commented May 18, 2021

As a GraphQL Content API User I want to be able to specify in the GraphQL query if a given field should be returned velocity-rendered in the response.

One way of achieving this would be by passing an GraphQL argument to the field indicating so.

Example:

{
  webPageContentCollection(query: "+identifier:911868a2-b1f5-475a-bd70-1def8a12f331") {
    title
    body(render: true)
    myTextArea(render: false)
    identifier
  }
}
@dsilvam dsilvam linked a pull request May 18, 2021 that will close this issue
@dsilvam dsilvam added this to the Falcon Current milestone May 19, 2021
@dsilvam dsilvam self-assigned this May 19, 2021
@wezell
Copy link
Contributor

wezell commented May 19, 2021

This is how you get both the rendered and the raw version - using aliases

webPageContentCollection(query: "+identifier:11c6ce1a-bdfe-4468-af81-33b4be3ea6ed") {
    title
    identifier
    rawBody: body(render: false)
    renderedBody: body(render: true)
    myTextArea(render: false)
  }

dsilvam added a commit that referenced this issue May 20, 2021
dsilvam added a commit that referenced this issue May 20, 2021
dsilvam added a commit that referenced this issue May 21, 2021
* Add argument to render a field in GraphQL Content API

* Remove unused imports`

* #20407 include contentlet in the velocity context

* #20407 Add constant field to the rendearble field group

* #20407 Postman tests

* #20407 test bundle
@dsilvam dsilvam reopened this May 21, 2021
@dsilvam dsilvam removed their assignment May 21, 2021
@dsilvam
Copy link
Contributor Author

dsilvam commented Jun 15, 2021

Note to QA/Doc:

GraphQL Contentlet fields now take a "render" parameter that will return the rendered value of the field. It only works for field of types: WysiwygField, TextField, TextAreaField, CustomField, ConstantField.

For QA: Postman test is GraphQL / Test Render Content Fields

@victoralfaro-dotcms
Copy link
Contributor

image
image

@victoralfaro-dotcms victoralfaro-dotcms self-assigned this Jun 15, 2021
dsilvam added a commit that referenced this issue Jun 22, 2021
dsilvam added a commit that referenced this issue Jun 22, 2021
dsilvam added a commit that referenced this issue Jun 22, 2021
dsilvam added a commit that referenced this issue Jun 23, 2021
* #20407 Return original field value if unable to render

* #20407 postman test

* #20407 resource for test

* #20407 fix location of resource
@dsilvam dsilvam linked a pull request Jun 23, 2021 that will close this issue
@bryanboza
Copy link
Member

Fixed, tested using the render parameter as in the provided example, also checked the postman test and both cases are working as expected. Tested on release-21.06 // Postgres

@dsilvam dsilvam changed the title Introduce ability to request velocity-rendering fields values in the GraphQL request Introduce ability to request velocity-rendered fields values in the GraphQL request Jul 7, 2021
@wezell wezell closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment