gened

I’d say it depends on your FE setup and what you want to achieve. A static site? or Next.js, CRA? I use gatsby and have a multiple sites one with 750+ pages and found it was far to expensive to build out each page with all the round trips to Silverstripe graphql. Instead build the data on the server and build the static site in one request from said built data

Anthony van Beek

Hey there! Going headless with React… what is a good solution to getting the pages from the CMS (nested pages)? All pages in one request or request per page? Say over +- 150 pages.

Bjorn Bojumble

yeah that was part of it. Thanks I have it kind of working now

👍 (1)
blueo

if so you may need :

  1. query myQuery {
  2. Regions {
  3. ID,
  4. Title
  5. }
  6. }
Bjorn Bojumble

right so Field "Regions" of type "[filter]" must have a sub selection

blueo

yeah i believe so - you can use the scaffolder to create the types from the region/topic data objects

Bjorn Bojumble

Should that be

  1. public function fields()
  2. {
  3. return [
  4. 'Regions' => ['type' => Type::listOf($this->manager->getType('region'))],
  5. 'Topics' => ['type' => Type::listOf($this->manager->getType('topic'))],
  6. ];
  7. }

And then define more types for region and topic?

Bjorn Bojumble

Yep Im trying that. In my type:

  1. public function fields()
  2. {
  3. return [
  4. 'Regions' => ['type' => Region::class],
  5. 'Topics' => ['type' => Topic::class],
  6. ];
  7. }

I think Ive got the types wrong above.

blueo

you could define your own type like so: https://github.com/silverstripe/silverstripe-graphql#define-types then have a custom query/resolver that returns your type (which has a list of regions/topics Type::listOf($this->manager->getType('region')))

Show 1 attachment(s)
GitHub  
silverstripe/silverstripe-graphql

Serves SilverStripe data as GraphQL representations - silverstripe/silverstripe-graphql

Hide attachment content