Skip to content

Remove ExtensibleSchema::addDefaultFallBackToTypeLoader #886

@ruudk

Description

@ruudk

While working on performance improvements for our large GraphQL application I noticed something odd.

I disabled config_validation, use_classloader_listener and auto_compile and noticed that for some queries \GraphQL\Type\Schema::getTypeMap was called. The description of that method warns that it's slow: "This operation requires full schema scan. Do not use in production environment.".

I notice this was because of a misconfiguration in my application. It couldn't find an EnumType and would then fallback to calling getType that would eventually call getTypeMap. That was able to find the type and register it properly.

See

try {
$type = $typeLoader($name);
} catch (UnresolvableException $e) {
// second chance for types with un-registered name in TypeResolver
// we disabled the custom typeLoader to force default loader usage
$schemaConfig->typeLoader = null;
$type = $this->getType($name);
$schemaConfig->typeLoader = $loaderWrapper;
}

Why is this fallback in place? Wouldn't it be better to fail immediately so that developers know their configuration is not right. Having these things automagically resolved is nice, but does not benefit performance and leaves bad config as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions