Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Can the CF Schema be used to filter Content Fragments in an AEM Sites implementation?

Avatar

Community Advisor

Hello,

 

For a headless implementation, its recommended to use GraphQL for filtering Content Fragments. Its a strict NO to use Querybuilder. The reason is GraphQL uses the Schema underlining the CF, which assures better query performance.

 

  • It is possible to execute GraphQL queries to generate content from CF in context of AEM Sites? Or any other way that AEM Sites could benefit from the CF Schema?
  • Or should querybuilder be used for AEM Sites and GraphQL for HTTP requests only?

 


Aanchal Sikka

1 Accepted Solution

Avatar

Correct answer by
Administrator

Yes, it is possible to execute GraphQL queries to generate content from Content Fragments (CFs) in the context of AEM Sites. You can do this using the AEM GraphQL Client, which is a JavaScript library that provides a simple way to make GraphQL queries to AEM.

One way to benefit from the CF schema in AEM Sites is to use it to dynamically generate the structure of your pages. For example, you could use GraphQL to query for all of the CFs of a certain type, and then use the schema to determine how to render those CFs on the page.

Another way to benefit from the CF schema in AEM Sites is to use it to validate user input. For example, you could use GraphQL to query for the schema of a CF before accepting input from a user, and then use the schema to validate the input.

Should QueryBuilder be used for AEM Sites and GraphQL for HTTP requests only?

As a general rule of thumb, it is recommended to use GraphQL for all headless content delivery, including content delivery to AEM Sites. This is because GraphQL offers a number of advantages over QueryBuilder, including:

  • Better performance: GraphQL queries are more efficient than QueryBuilder queries because they only return the data that is specifically requested.
  • More flexibility: GraphQL queries can be used to retrieve any data from AEM, regardless of the structure of the content. QueryBuilder queries, on the other hand, are limited to retrieving data from specific fields in specific content types.
  • Better developer experience: GraphQL is a more modern and developer-friendly API than QueryBuilder.

However, there are a few cases where it may make sense to use QueryBuilder instead of GraphQL:

  • If you need to query for a large amount of data: QueryBuilder queries can be more efficient than GraphQL queries when retrieving a large amount of data.
  • If you need to query for data from a custom content type: QueryBuilder can be used to query for data from custom content types, which are not supported by GraphQL.
  • If you are already familiar with QueryBuilder: If you are already familiar with QueryBuilder, it may be easier to use it than to learn GraphQL.

Overall, GraphQL is the recommended API for headless content delivery in AEM Sites. However, there are a few cases where it may make sense to use QueryBuilder instead.

 

Documentation: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/sites/administering... 



Kautuk Sahni

View solution in original post

1 Reply

Avatar

Correct answer by
Administrator

Yes, it is possible to execute GraphQL queries to generate content from Content Fragments (CFs) in the context of AEM Sites. You can do this using the AEM GraphQL Client, which is a JavaScript library that provides a simple way to make GraphQL queries to AEM.

One way to benefit from the CF schema in AEM Sites is to use it to dynamically generate the structure of your pages. For example, you could use GraphQL to query for all of the CFs of a certain type, and then use the schema to determine how to render those CFs on the page.

Another way to benefit from the CF schema in AEM Sites is to use it to validate user input. For example, you could use GraphQL to query for the schema of a CF before accepting input from a user, and then use the schema to validate the input.

Should QueryBuilder be used for AEM Sites and GraphQL for HTTP requests only?

As a general rule of thumb, it is recommended to use GraphQL for all headless content delivery, including content delivery to AEM Sites. This is because GraphQL offers a number of advantages over QueryBuilder, including:

  • Better performance: GraphQL queries are more efficient than QueryBuilder queries because they only return the data that is specifically requested.
  • More flexibility: GraphQL queries can be used to retrieve any data from AEM, regardless of the structure of the content. QueryBuilder queries, on the other hand, are limited to retrieving data from specific fields in specific content types.
  • Better developer experience: GraphQL is a more modern and developer-friendly API than QueryBuilder.

However, there are a few cases where it may make sense to use QueryBuilder instead of GraphQL:

  • If you need to query for a large amount of data: QueryBuilder queries can be more efficient than GraphQL queries when retrieving a large amount of data.
  • If you need to query for data from a custom content type: QueryBuilder can be used to query for data from custom content types, which are not supported by GraphQL.
  • If you are already familiar with QueryBuilder: If you are already familiar with QueryBuilder, it may be easier to use it than to learn GraphQL.

Overall, GraphQL is the recommended API for headless content delivery in AEM Sites. However, there are a few cases where it may make sense to use QueryBuilder instead.

 

Documentation: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/sites/administering... 



Kautuk Sahni