SR
Click to open github profile
Usage

Settings

Learn about all of the settings of the craft query API


You can define a multi environment aware config in craft/config/craft-query-api.php. You can find an example in that file.

cacheDuration

Defines the cache duration. Defaults to the cache duration defined in your general.php.

return [
 'production' => [
   'cacheDuration' => 3600, // cache for 1h
 ]
]

excludedFieldClasses

Define field classes that should be excluded from the json response. Used for example for excluding the seo settings field, because SEOmatic has its own API endpoint for that.

return [
 'production' => [
   'excludeFieldClasses' => ['nystudio107\seomatic\fields\SeoSettings'],
 ]
]

includeAllEntry

Defines how entry relations from an Entries field are returned. If enabled, the customQuery endpoint will include full entry objects, otherwise only minimal data (title, URI, ID, slug) is returned.

return [
  '*' => [
    'includeAllEntry' => true,
  ]
]
Warning

If you use this, be sure that you don't have circular entry relations. This would end up in an endless loop.

typeGenerationMode

Determines how ts types for your frontend should be created.

Manuel

Set it to manuel if you want to create your type definitions manually with the craft query-api/generate-types command.

return [
  'dev' => [
    'typeGenerationMode' => 'manual',
  ]
]

Auto

Set it to auto if you want to recreate your type definitions on demand, everything your project config changes.

return [
  'dev' => [
    'typeGenerationMode' => 'auto',
  ]
]
Warning

This will only run if you change the project config through the Craft CMS control panel. If you run craft project-config/apply it will NOT run. Then you have to do it manually with the craft query-api/generate-types command.

typeGenerationOutputPath

Defines where ts definitions get created. Aliases can be used here as well.

return [
  'dev' => [
    'typeGenerationOutputPath' => '@root/queryApiTypes.ts',
  ]
]

Copyright © 2025 Samuel Reichör