Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dam Assets only appear in DevMode bug #33

Closed
ericdrosas87 opened this issue Mar 28, 2023 · 3 comments
Closed

Dam Assets only appear in DevMode bug #33

ericdrosas87 opened this issue Mar 28, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ericdrosas87
Copy link
Contributor

"For some time I've been puzzling around why we can operate our site in production mode, I believe I have finally discovered the issue and I think it is related to the way DAM Asset data is stored.

Current Behavior
With rubin-obs-api CRAFT_ENVIRONMENT= dev, DAM Asset fields are populated in the control panel, and associated fields are queryable via graphQL. With rubin-obs-api CRAFT_ENVIRONMENT= production, previously populated DAM Asset fields are blank in the control panel, and associated fields are not queryable via graphQL (return null). DAM Assets field does allow new selection, and while they appear to save, they are still not accessible via graphQL.

Expected Behavior
DAM Asset fields are populated in the control panel, and associated fields are queryable via graphQL regardless of CRAFT_ENVIRONMENT setting.

Steps to Reproduce
To reproduce this behavior see "example query.json", "example variables" for snippets to copy and paste into craft graphQL explorer. Set the CRAFT_ENVIRONMENT variable accordingly, and then observe difference in response: see "devMode response.json" and "prodMode response.json" files to see responses generated in graphQL explorer in respective environments."

From Blake

@ericdrosas87
Copy link
Contributor Author

Stack trace:

2023-03-29 21:00:56 [web.ERROR] [craft\errors\GqlException] Tried to load an unregistered type "DAMAssetInterface". This can indicate both a typo in the query or an issue with the schema used. {"trace":["#0 /var/www/html/vendor/webonyx/graphql-php/src/Type/Schema.php(350): craft\gql\TypeLoader::loadType()","#1 /var/www/html/vendor/webonyx/graphql-php/src/Type/Schema.php(326): GraphQL\Type\Schema->loadType()","#2 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(765): GraphQL\Type\Schema->getType()","#3 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#4 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(887): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#5 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(761): GraphQL\Executor\ReferenceExecutor->completeListValue()","#6 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(741): GraphQL\Executor\ReferenceExecutor->completeValue()","#7 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#8 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(557): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#9 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1195): GraphQL\Executor\ReferenceExecutor->resolveField()","#10 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1145): GraphQL\Executor\ReferenceExecutor->executeFields()","#11 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1106): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()","#12 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(974): GraphQL\Executor\ReferenceExecutor->completeObjectValue()","#13 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(789): GraphQL\Executor\ReferenceExecutor->completeAbstractValue()","#14 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#15 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(887): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#16 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(761): GraphQL\Executor\ReferenceExecutor->completeListValue()","#17 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(741): GraphQL\Executor\ReferenceExecutor->completeValue()","#18 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#19 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(557): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#20 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1195): GraphQL\Executor\ReferenceExecutor->resolveField()","#21 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1145): GraphQL\Executor\ReferenceExecutor->executeFields()","#22 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1106): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()","#23 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(974): GraphQL\Executor\ReferenceExecutor->completeObjectValue()","#24 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(789): GraphQL\Executor\ReferenceExecutor->completeAbstractValue()","#25 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#26 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(887): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#27 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(761): GraphQL\Executor\ReferenceExecutor->completeListValue()","#28 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#29 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(557): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#30 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1195): GraphQL\Executor\ReferenceExecutor->resolveField()","#31 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1145): GraphQL\Executor\ReferenceExecutor->executeFields()","#32 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1106): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()","#33 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(974): GraphQL\Executor\ReferenceExecutor->completeObjectValue()","#34 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(789): GraphQL\Executor\ReferenceExecutor->completeAbstractValue()","#35 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(654): GraphQL\Executor\ReferenceExecutor->completeValue()","#36 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(557): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()","#37 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1195): GraphQL\Executor\ReferenceExecutor->resolveField()","#38 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(264): GraphQL\Executor\ReferenceExecutor->executeFields()","#39 /var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(215): GraphQL\Executor\ReferenceExecutor->executeOperation()","#40 /var/www/html/vendor/webonyx/graphql-php/src/Executor/Executor.php(156): GraphQL\Executor\ReferenceExecutor->doExecute()","#41 /var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php(162): GraphQL\Executor\Executor::promiseToExecute()","#42 /var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php(94): GraphQL\GraphQL::promiseToExecute()","#43 /var/www/html/vendor/craftcms/cms/src/services/Gql.php(512): GraphQL\GraphQL::executeQuery()","#44 /var/www/html/vendor/craftcms/cms/src/controllers/GraphqlController.php(177): craft\services\Gql->executeQuery()","#45 [internal function]: craft\controllers\GraphqlController->actionApi()","#46 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()","#47 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()","#48 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()","#49 /var/www/html/vendor/craftcms/cms/src/web/Application.php(302): yii\base\Module->runAction()","#50 /var/www/html/vendor/craftcms/cms/src/web/Application.php(627): craft\web\Application->runAction()","#51 /var/www/html/vendor/craftcms/cms/src/web/Application.php(281): craft\web\Application->_processActionRequest()","#52 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()","#53 /var/www/html/web/index.php(23): yii\base\Application->run()","#54 {main}"],"memory":70056208,"exception":"[object] (craft\errors\GqlException(code: 0): Tried to load an unregistered type "DAMAssetInterface". This can indicate both a typo in the query or an issue with the schema used. at /var/www/html/vendor/craftcms/cms/src/gql/TypeLoader.php:39)"}

@ericdrosas87
Copy link
Contributor Author

ericdrosas87 commented Mar 29, 2023

I think I found the offending code.

This:

    public static function getType($fields = null): Type
    {
        if ($type = GqlEntityRegistry::getEntity(self::class)) {
            return $type;
        }

        $type = GqlEntityRegistry::createEntity(self::class, new InterfaceType([
            'name' => static::getName(),
            'fields' => self::class . '::getFieldDefinitions',
            'description' => 'This is the interface implemented by all DAM assets.',
            'resolveType' => function($value) {
                return GqlEntityRegistry::getEntity(DAMAssetGenerator::getName());
            }
        ]));

        DAMAssetGenerator::generateTypes();

        return $type;
    }

Should be:

public static function getType($fields = null): Type
    {
        $name = "DAMAssetInterface";
        if ($type = GqlEntityRegistry::getEntity($name)) {
            return $type;
        }

        $type = GqlEntityRegistry::createEntity($name, new InterfaceType([
            'name' => static::getName(),
            'fields' => self::class . '::getFieldDefinitions',
            'description' => 'This is the interface implemented by all DAM assets.',
            'resolveType' => function($value) {
                return GqlEntityRegistry::getEntity(DAMAssetGenerator::getName());
            }
        ]));

        DAMAssetGenerator::generateTypes();

        return $type;
    }

@ericdrosas87
Copy link
Contributor Author

This is fixed and out in production, the branch EPO-7854 will be merged into the main branch in the next week or so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants