spacecatninja / craft-imager-x

Image transforms, optimizations and manipulations for your Craft CMS site.
Other
26 stars 16 forks source link

"debugMessage": "Undefined index: transform", #211

Closed rpiprojectsmgmt closed 1 year ago

rpiprojectsmgmt commented 1 year ago
### I'm submitting a...

Steps to reproduce

fetch any asset in Graphql using asset interface imagerTransform

Description

It should return the transformed set of data for the asset ### Displayed errors, stack trace, relevant logs [](https://monosnap.com/file/26Lyimk4S5njFcWzf6rfiD4wkOzb0j) ``` PASTE THE ERROR MESSAGE / STACK TRACE HERE { "debugMessage": "Undefined index: transform", "message": "Internal server error", "extensions": { "category": "internal" }, "file": "/var/www/aftertheendofthe.world/new/craft/vendor/spacecatninja/imager-x/src/gql/resolvers/ImagerResolver.php", "line": 31, "trace": [ { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/web/ErrorHandler.php", "line": 84, "call": "yii\\base\\ErrorHandler::handleError(8, 'Undefined index: transform', '/var/www/aftertheendofthe.world/new/craft/vendor/spacecatninja/imager-x/src/gql/resolvers/ImagerResolver.php', 31)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/spacecatninja/imager-x/src/gql/resolvers/ImagerResolver.php", "line": 31, "call": "craft\\web\\ErrorHandler::handleError(8, 'Undefined index: transform', '/var/www/aftertheendofthe.world/new/craft/vendor/spacecatninja/imager-x/src/gql/resolvers/ImagerResolver.php', 31, array(5))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 623, "call": "spacecatninja\\imagerx\\gql\\resolvers\\ImagerResolver::resolve(instance of craft\\elements\\Asset, array(0), array(2), instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 554, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, 'spacecatninja\\imagerx\\gql\\resolvers\\ImagerResolver::resolve', instance of craft\\elements\\Asset, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1195, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: editorialAssets_Asset, instance of craft\\elements\\Asset, instance of ArrayObject(1), array(5))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1145, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: editorialAssets_Asset, instance of craft\\elements\\Asset, array(4), instance of ArrayObject(2))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1109, "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: editorialAssets_Asset, instance of ArrayObject(1), array(4), instance of craft\\elements\\Asset)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 983, "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: editorialAssets_Asset, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\Asset)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 789, "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\Asset)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 654, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\Asset)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 887, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(4), instance of craft\\elements\\Asset)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 761, "call": "GraphQL\\Executor\\ReferenceExecutor::completeListValue(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 654, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 561, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: AssetInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(3), array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1195, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: event_event_Entry, instance of craft\\elements\\Entry, instance of ArrayObject(1), array(3))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1145, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: event_event_Entry, instance of craft\\elements\\Entry, array(2), instance of ArrayObject(2))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1109, "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: event_event_Entry, instance of ArrayObject(1), array(2), instance of craft\\elements\\Entry)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 983, "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: event_event_Entry, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\Entry)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 789, "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\Entry)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 654, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\Entry)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 887, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of craft\\elements\\Entry)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 761, "call": "GraphQL\\Executor\\ReferenceExecutor::completeListValue(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1059))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 654, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1059))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 561, "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: EntryInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), array(1059))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 1195, "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: Query, null, instance of ArrayObject(1), array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 264, "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: Query, null, array(0), instance of ArrayObject(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 215, "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/Executor/Executor.php", "line": 156, "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/GraphQL.php", "line": 169, "call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, instance of GraphQL\\Language\\AST\\DocumentNode, null, array(2), null, 'MyQuery', null)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/webonyx/graphql-php/src/GraphQL.php", "line": 102, "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, 'query MyQuery {\n entries {\n ... on event_event_Entry {\n id\n bannerGraphic {\n id\n imagerTransform {\n id\n }\n }\n }\n }\n}\n', null, array(2), null, 'MyQuery', null, array(26))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/services/Gql.php", "line": 546, "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, 'query MyQuery {\n entries {\n ... on event_event_Entry {\n id\n bannerGraphic {\n id\n imagerTransform {\n id\n }\n }\n }\n }\n}\n', null, array(2), null, 'MyQuery', null, array(26))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/controllers/GraphqlController.php", "line": 172, "call": "craft\\services\\Gql::executeQuery(instance of craft\\models\\GqlSchema, 'query MyQuery {\n entries {\n ... on event_event_Entry {\n id\n bannerGraphic {\n id\n imagerTransform {\n id\n }\n }\n }\n }\n}\n', null, 'MyQuery', true)" }, { "call": "craft\\controllers\\GraphqlController::actionApi()" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/yiisoft/yii2/base/InlineAction.php", "line": 57, "function": "call_user_func_array(array(2), array(0))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/yiisoft/yii2/base/Controller.php", "line": 178, "call": "yii\\base\\InlineAction::runWithParams(array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/yiisoft/yii2/base/Module.php", "line": 552, "call": "yii\\base\\Controller::runAction('api', array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/web/Application.php", "line": 293, "call": "yii\\base\\Module::runAction('graphql/api', array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/web/Application.php", "line": 602, "call": "craft\\web\\Application::runAction('graphql/api', array(1))" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/craftcms/cms/src/web/Application.php", "line": 272, "call": "craft\\web\\Application::_processActionRequest(instance of craft\\web\\Request)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/vendor/yiisoft/yii2/base/Application.php", "line": 384, "call": "craft\\web\\Application::handleRequest(instance of craft\\web\\Request)" }, { "file": "/var/www/aftertheendofthe.world/new/craft/web/index.php", "line": 22, "call": "yii\\base\\Application::run()" } ] }, ### Additional info - v3.6.5 - Imager transformer: - Craft version: 3 - PHP version: 7.2 - Image driver & version: Imagemagick
aelvan commented 1 year ago

Hi,

I'm not able to reproduce, as far as I can tell the imagerTransform query still works as it should. Can you share your GQL query?

aelvan commented 1 year ago

The error indicates that you didn't supply the transform param to the query, it is required, ie:

{
    hero: imagerTransform(id: 340, transform: "heroImage") {
        url,
        width,
        height,
        size,
        extension,
        mimeType
  }
}
rpiprojectsmgmt commented 1 year ago

we tried your code and still we are facing issues let me share some screenshots that may help https://monosnap.com/file/1PXnQkM67reD4b4sMjWD5UyIPuo2sl https://monosnap.com/file/FIemipD1DRzWSAzChcpTiDRPWNVBoO

aelvan commented 1 year ago

When you use the imagerTransform query inside another query, you should not pass the id parameter. That's only for when you do a separate base query with it. The main error in your code is that you don't do the imager query on an asset interface, as shown on the documentation (last example here). Also, there's no id attribute in the data that comes from Imager.

Something like this should work:

query MyQuery {
  entries {
    ... on event_event_Entry {
      id
      bannerGraphic {
        url,
        ... on your_volume_handle_Asset {
          transform: imagerTransform(transform: "bannerGraphic") {
            url
          }
        }
      }
    }
  }
}

Key point here is ... on your_volume_handle_Asset { (substitute your_volume_handle with the handle for the volume), and that I've removed id both as a parameter, and as a property inside the imagerTransform.

It would've been helpful if you'd pasted the actual code instead of screenshots, much easier to patch that instead of rewriting you code.

Hope this helps.

rpiprojectsmgmt commented 1 year ago

we tried it please check it still gave us errors https://monosnap.com/file/2qPdM03eMjC7Wmy7WW3v1BWTnDkjii https://monosnap.com/file/nRr5uCN7DrXXBsXxSF2vBj5fdHYMSJ

rpiprojectsmgmt commented 1 year ago

hellow can you guys please get back to us on it it is extremely urgent we need to get this done

aelvan commented 1 year ago

The code in the second screenshot (https://monosnap.com/file/nRr5uCN7DrXXBsXxSF2vBj5fdHYMSJ) looks correct to me, and doesn't create an error per se.

The instances where there is an empty array for bannerGraphic indicates that there is a field called that, but that there isn't an asset in it. The instances where there is an array for bannerGraphic, with an empty object, indicates that there is an asset in the bannerGraphic field, but not on a volume with handle communityAssets.

rpiprojectsmgmt commented 1 year ago

Hi no that is not the case we have data and we have the URL on it as well as we are getting normal URLs but not the transformed images.That is still null and please check the other code as well with the error https://monosnap.com/file/1tS6advv6sjkvU8xaPwSTcMDJOttGI https://monosnap.com/file/2YRy8PpOQvSV8BtV5rva5gfEWcTyUU

aelvan commented 1 year ago

You are now sharing completely different code and errors.

aelvan commented 1 year ago

And why are you sharing two errors every time? One of which is always wildly wrong?

rpiprojectsmgmt commented 1 year ago

The code is the same I followed your process and then added the correct asset folder still the data is null plus the other set that is giving the error is from a local staging setup where we use graphql in gatsby react. Since your plugin claims to support graphql we want this thing to work in both spaces as we will pull transformed images in the front end. Please guide us where we are going wrong. Or is there any error in our version of the plugin being provided by you? Or your graphql support has some issues. we want this to work hence we bought the pro version for Graphql support

aelvan commented 1 year ago

The code in the first screenshot (https://monosnap.com/file/1tS6advv6sjkvU8xaPwSTcMDJOttGI) seems to be correct, but Imager returns null for some reason. Check you log files, there should be something explaining why. Also, testing that transforms work from twig will probably be an easier route to debug such issues.

I'm not familiar with gatsby, are you using gatsby-source-craftcms to integrate with Craft?

rpiprojectsmgmt commented 1 year ago

Hello i tried the entire day but it is not generating any logs in the Craft storage logs area.I am not familiar with twig can you please explain in detail so that I can debug yes we are using gatsby-source-craftcms to integrate with craft

rpiprojectsmgmt commented 1 year ago

hellow waiting for your reply have you come up with some new ideas that can help us please

aelvan commented 1 year ago

A basic twig template to test if Imager works would be:

{% set asset = craft.assets.id(someId).one() %}
{% set transform = craft.imagerx.transformImage(asset, 'headerImage') %}
{{ transform|srcset }} OR {{ transform.url }} depending on if headerImage is an array of transforms or a single transform

As to the gatsby variant, I'm not sure if that source plugin would pick up on things that plugins add to Craft, but I would have to check with P&T about that. First step would be to get it to work in Craft anyway.

Also, feel free to reach out to P&T to get a refund on the purchase if you can't get it to work. I can't help you with project specific issues, all I can verify is that the Imager GraphQL functionality works as expected.

rpiprojectsmgmt commented 1 year ago

Can you please check once with P&T for the Gatsby react graphql support cause that would help us a lot. As per craft, we did try working it out but the result is still null . We would be extremely grateful to you if someone from your team can connect with us and help us out with this.

aelvan commented 1 year ago

Did you try doing it from twig? Did you check the debug toolbar and the logs for errors?