Uploaded image for project: 'Magnolia GraphQL'
  1. Magnolia GraphQL
  2. MGNLGQL-48

Sanitize content type names when creating GraphQL schemas

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Neutral
    • None
    • None
    • None

    Description

      Problem description

      Ever since DOCS57, we have been implicitly allowing dashes in content type filenames:

      (https://documentation.magnolia-cms.com/display/DOCS62/Content+type+definition)

      However, dashes create an issue for GraphQL schemas:

      2020-08-19 08:48:51,572 ERROR info.magnolia.event.SimpleEventBus                : Exception caught when dispatching info.magnolia.graphql.core.GraphQLDefinitionChangedEvent with info.magnolia.graphql.core.GraphQLProvider$$Lambda$786/1987165365 eventHandler.
      graphql.AssertException: Name must be non-null, non-empty and match [_A-Za-z][_0-9A-Za-z]* - was 'Bookshelf-app'
      	at graphql.Assert.assertValidName(Assert.java:107) ~[graphql-java-14.1.jar:?]
      	at graphql.schema.FieldCoordinates.assertValidNames(FieldCoordinates.java:50) ~[graphql-java-14.1.jar:?]
      

      https://spec.graphql.org/June2018/#sec-Names

      (2.1.9 Names):

      Name
      /[_A-Za-z][_0-9A-Za-z]*/
      GraphQL Documents are full of named things: operations, fields, arguments, types, directives, fragments, and variables. All names must follow the same grammatical form.

      Names in GraphQL are case‐sensitive. That is to say nameName, and NAME all refer to different names. Underscores are significant, which means other_name and othername are two different names.

      Names in GraphQL are limited to this ASCII subset of possible characters to support interoperation with as many other systems as possible.

       

      Task

      We should either:

      • Introduce a sanitizer for GraphQL schema generation in case a content type name contains dashes.
      • Or, let the users be aware of this and recommend some unifying best practice for (CT) name creation, such as resorting to camel case, the same way we do this for folder names:

       

       

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                Unassigned Unassigned
                mdrapela Martin Drápela
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:

                  Checklists

                    Task DoR