/neos-cr-graphql-distribution

Experimental distribution for setting up Neos CMS with GraphQL

Primary LanguagePHP

Neos Content Repository Graphql Adapter

This is a prototype distribution to add a headless approach to the Neos ContentRepository

Idea

Based on a discussion at the Vienna Sprint (14.10.2019) we agreed to kickstart a prototype to add a headless option to the Neos ContentRepository. This should be achieved with GraphQL.

While providing only all basic types and queries the package should be easily extensible.

The Content Repository adapter should be able to read all available NodeTypes and create a autogenerated sdl including GraphQL Types for all of your NodeTypes.

Get started

  1. Generate the missing schema:
./flow schemagenerator:generate

This command will output a types.grapqhl file at PROJECT_DIR/Data/SchemaGenerator. Move this file to DistributionPackages/CustomApp/Resources/Private/GraphQL/schema.nodetypes.graphql

This step should be handled later via the console just like we do it with doctrine migrations.

  1. Generate some node data
./flow fixtures:insert

Generate some random nodes and persist them.

  1. Start the server:
./flow server:run

You should now be able to run GraphQL queries against the endpoint http://127.0.0.1:8081/graphql:

query {
  nodeByPath(path: "/dac9b396-35c9-4e85-b2f4-e2f89febeaa3"}) {
    identifier
    path
    name
    workspace {
      name
      title
    }
    
    context {
      workspaceName
    }
    
    ... on NeosContentRepositoryTestingText {
      properties {
        text
      }
    }
    
    ... on NeosContentRepositoryTestingHtml {
      properties {source
      }
    }
  }
}

Packages included in this distribution

Neos.CR.GraphQL

This package acts as an Adapter to the Neos ContentRepository. It will provide all base resolver and type definitions for a Node, Context, Workspace etc. It will also provide a SchemaGenerator that converts all available NodeTypes to a valid GraphQL schema.

Custom.App

This is a fake package that acts as the actually "Application". Later on the app has to configure the GraphQL Endpoint.

Missing Packages

Neos.CR.GraphQL.Read

Provide some basic queries to fetch node data as well as some filter mechanism to scroll through your result list

Neos.CR.GraphQL.Write

Running mutations against the ContentRepository