Problem/Motivation

After updating to 5.0.0-alpha3, I get a lot of errors like this in the logs:

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: Failed to read schema file "modules/custom/MY_MODULE/graphql/base.extension.graphqls". in Drupal\graphql\Plugin\GraphQL\SchemaExtension\SdlSchemaExtensionPluginBase->loadDefinitionFile() (line 111 of .../web/modules/contrib/graphql/src/Plugin/GraphQL/SchemaExtension/SdlSchemaExtensionPluginBase.php).

Steps to reproduce

The MY_MODULE/graphql/base.extension.graphqls file is an empty file.

I don't know if there are any actual visible failures, but the errors are worrying so I'm reverting the update for now.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#5 message.PNG3.58 KBangel_devoeted

Issue fork graphql-3587476

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

solideogloria created an issue. See original summary.

kingdutch made their first commit to this issue’s fork.

kingdutch’s picture

Title: Errors after updating: Failed to read schema file » Clarify that schema files may not be empty
Status: Active » Needs review

Thanks for the report! This is an intentional change due to the adoption of Source instances with source location information for better debugging. Unfortunately it does not support empty strings, so this is a behaviour change.

I've pushed a fix to clarify the exception being thrown and show this is intentional, I've also added a change record to the original issue (and linked it to this one) to better clarify this change and provide the proposed solution.

angel_devoeted’s picture

StatusFileSize
new3.58 KB

Tested MR !90 on Drupal Forge and confirmed it works as expected. Empty schema files now trigger a clear InvalidPluginDefinitionException with the specific message, instead of a generic failure.

message

solideogloria’s picture

Status: Needs review » Reviewed & tested by the community
kingdutch’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • kingdutch committed 28c9967f on 5.x
    fix: #3587476 Clarify that schema files may not be empty
    
klausi’s picture

Status: Fixed » Active

Unfortunately this breaks our use case, so we will have to revert parts of this.

A graphql extension module can have an extension definition, but not a base definition.

Example:
jobiqo_analytics.base.graphqls: empty or should not exist
jobiqo_analytics.extension.graphqls: contains extensions like

extend type Job {
  """
  Analytics performance data job visits.
  """
  analyticsJobVisits: Int
  """
  Analytics performance data job apply start.
  """
  analyticsJobApplyStart: Int
  """
  Analytics performance data job apply complete.
  """
  analyticsJobApplyComplete: Int
}

Proposed solution: allow empty and missing *.graphqls files.

klausi’s picture

Status: Active » Needs review

MR created, if you are ok with the approach I can add a test case.

klausi’s picture

Status: Needs review » Fixed

Sorry, I should have a read the change notice ...

So that should also work for us, hopefully not too many schema extension classes to update.

Setting this back to fixed for now.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.