Updating a GraphQL Schema

The Cook needs a GraphQL schema describing the structure of the content it has access to – that is, the structure of the publication. The CUE Front start pack includes a schema for the demo publication in its schema folder. If you want to create a presentation layer for your own publication, then the first step is to replace these files with files that describe your publication.

A shell script for generating new schema files based on any CUE publication is included in the start pack. In order to use the script you must have access to the publication you want to work with. In the cue-front folder, enter:

docker-compose exec cook bin/update-schema.sh publication-name user:password http://my-escenic.com:8080/webservice/

or, if your Content Store installation includes CUE Live, enter:

docker-compose exec cook bin/update-schema.sh publication-name user:password http://my-escenic.com:8080/webservice/ http://my-escenic.com:8080/live-center-editorial/

The script's parameters are:

  • The name of the publication

  • Credentials for accessing the publication

  • The URL of the Content Store's webservice. The URL must be terminated with a /.

  • The URL of the CUE Live presentation webservice. The URL must be terminated with a /. This parameter should only be supplied if your Content Store installation includes CUE Live

The update-schema.sh script sends a series of requests to the specified web service(s), and retrieves the information it needs to generate a complete description of the publication structure in the form of Javascript schema files. It writes these files to the cue-front/schema folder. You will see that it generates an index.js for section pages, one .js file for each content type defined in the publication's content-type resource and one .js file for each group defined in the publication's layout-group resource. If CUE Live is installed, then it also creates a schema/entryTypes folder containing a .js file for each CUE Live entry type.

Important notes
  • If your Content Store is running in a virtual machine exposed on localhost, you cannot use localhost in the web service parameters supplied to update-schema.sh, as this will be interpreted to mean the Cook container's local host rather than your PC. You need to specify your computer's actual IP address instead. You should, for example specify http://ip-address:8080/webservice/ instead of http://localhost:8080/webservice/.

  • In order for your changes to take effect, you must restart the Cook after updating the schema:

    docker-compose restart cook
  • The schema must be updated not only when setting up CUE Front to handle a new publication, but also any time you modify the publication's content-type resource or layout-group resource. If CUE Live is installed at your site, then you must also update the schema after modifying the entry-type resource. First upload the modified resources to the Content Store, and then run update-schema.sh using one of the commands listed above.