Skip to content

When having GraphQL, an exception occurs when Twig is not enabled #4897

Description

@rvanlaak

API Platform version(s) affected: 3.0.0-rc.2

Description

The API Platform GraphiQL integration seems to have a dependency on the twig service, but that leads to an compilation exception when Twig is not enabled for the active environment.

image

How to reproduce

  • require webonyx/graphql-php to enable GraphQL for api-platform
  • but do not enable TwigBundle in bundles.php for the active environment (e.g. prod).

Possible Solution

Do not enable the visual graphiQL playground when Twig service is not available or bundle is not enabled.

Additional Context

see documentation https://api-platform.com/docs/core/graphql/#graphiql

Our use-case is that we do not want to have Twig enabled on our prod environment because we only support json and xml content types.

  • Enabling TwigBundle in bundles.php for all environments solves the exception but is not preferable
  • Disabling graphiql does not solve the exception:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions