Demonstrates an very basic JSS Application written using React with GraphQL.
Consult the primary JSS documentation at https://jss.sitecore.net for the latest documentation on JSS.
First run yarn to install dependencies.
This is required as a prerequisite to running this application, and can also be used for ongoing deployment.
- Install the JSS server components on your local Sitecore installation according to the JSS documentation
- Install
Sitecore.Services.GraphQLaccording to its documentation, including the examples and JSS assembly yarn setupto configure the connection to a local Sitecore installation- Review the application config patch file in
sitecore/configto ensure that it is configured appropriately for your Sitecore installation. yarn deploy-configto deploy the Sitecore config patch file to the Sitecore instance (you may need to add thehostNameto yourhostsfile)- Use
yarn deploy-codefirstto deploy the sample app's code and items to Sitecore - Visit
http://jssbasicappgraphqlto see the demonstration running in Sitecore
Use yarn start:connected to run a local development server. Sitecore is required, and content data is pulled from Sitecore. The app is hosted using a local webserver, however, and is not integrated with Sitecore.
Use yarn deploy:watch to start a constant build/copy to Sitecore script. Change a file, refresh app in Sitecore, see updates. This will cause the app to be rendered server-side by Sitecore ('integrated mode') and then subsequent transitions are handled on the client.
In order to properly match up GraphQL interface types that are used in GraphQL fragments to the Apollo Client cache, it's necessary for Apollo to know a bit about your GraphQL schema. When adding or removing new components that are part of your application (or any other Sitecore Template that your application uses), ensure that you run yarn graphql:update-schema after the changes are present in Sitecore. This will pull the latest GraphQL introspection data local so that the Apollo cache will keep your data cached without any mistakes. Commit any changes to the sitecore/GraphQLFragmentTypes.json file that result from this update.