You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a pre-built schema if that's what they want.$interfaces = [
EntryInterface::class,
MatrixBlockInterface::class,
AssetInterface::class,
UserInterface::class,
GlobalSetInterface::class,
ElementInterface::class,
CategoryInterface::class,
TagInterface::class,
];
foreach ($interfacesas$interfaceClass) {
if (!is_subclass_of($interfaceClass, InterfaceType::class)) {
thrownewGqlException('Incorrectly defined interface ' . $interfaceClass);
}
/** @var GeneratorInterface $typeGeneratorClass */$typeGeneratorClass = $interfaceClass::getTypeGenerator();
foreach ($typeGeneratorClass::generateTypes() as$type) {
$schemaConfig['types'][] = $type;
}
}
Craft iterates through a hard-coded list of Interfaces, and generates the the types for them... but since plugins are not given a chance to be added to said hard-coded list, they fail.
This is a "soft error" in the GraphQL implementation in Craft, but the Apollo layer added via Gatsby and Gridsome do additional type checking to ensure that the returned data matches a registered type:
"use strict";Object.defineProperty(exports,"__esModule",{value: true});vargraphql_1=require("graphql");functionresolveFromParentTypename(parent,schema){varparentTypename=parent['__typename'];if(!parentTypename){thrownewError('Did not fetch typename for object, unable to resolve interface.');}varresolvedType=schema.getType(parentTypename);if(!(resolvedTypeinstanceofgraphql_1.GraphQLObjectType)){thrownewError('__typename did not match an object type: '+parentTypename+' -- '+JSON.stringify(schema));}returnresolvedType;}exports.default=resolveFromParentTypename;//# sourceMappingURL=resolveFromParentTypename.js.map
...which fails, throwing an error.
I manually added my SeomaticInterface to the hard-coded list above, and everything worked peachy:
SEOmatic (and Retour) both register GraphQL Interfaces -- which define generators that return objects for GraphQL to use.
The issue is here:
https://github.com/craftcms/cms/blob/develop/src/services/Gql.php#L232
Craft iterates through a hard-coded list of Interfaces, and generates the the types for them... but since plugins are not given a chance to be added to said hard-coded list, they fail.
This is a "soft error" in the GraphQL implementation in Craft, but the Apollo layer added via Gatsby and Gridsome do additional type checking to ensure that the returned data matches a registered type:
...which fails, throwing an error.
I manually added my
SeomaticInterface
to the hard-coded list above, and everything worked peachy:Ref: nystudio107/craft-seomatic#487 (comment)
The text was updated successfully, but these errors were encountered: