Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-31240

Querying for contentobjects missing ImageAsset FieldType in GraphQL ends up with an error

    XMLWordPrintable

Details

    Description

      Currently, when CT definition is modified by adding ImageAsset FieldType and regenerating GraphQL schema, querying by objects which were created before the update ends up with an error.

      Steps to reproduce:
      1. Create a fresh installation of eZ Platform.
      2. Create a new CT "testCT" in "Content" group and add ezstring FieldType named "text" to its definition.
      3. Publish the new CT and regenerate GraphQL schema: php bin/console ezplatform:graphql:generate-schema.
      4. Create a new content object using this CT.
      5. Visit your_site.com/graphiql and query for all the content objects created using this new CT:

      {
        content {
          testCTs {
            edges {
              node {
                text
              }
            }
          }
        }
      }
      

      the query returns a proper result.
      6. Modify "testCT" definition by adding another FieldType ImageAsset and naming it img.
      7. Regenerate GraphQL schema.
      8. Create another content object using this modified CT.
      9. Perform another query, but this time take img into account:

      {
        content {
          testCTs {
            edges {
              node {
                img {
                  uri
                  variation(identifier: large) {
                    uri
                  }
                }
                text
              }
            }
          }
        }
      }
      

      Result:
      The data for objects which contain values for both FieldTypes will be provided but you will be presented with an error first:

      Unsupported value (NULL)

      Expected result:
      The result is properly shown without throwing an Exception.

      Note:
      There is a missing check for destinationContentId https://github.com/ezsystems/ezplatform-graphql/blob/1.0/src/GraphQL/Resolver/ImageAssetFieldResolver.php#L41

      Attachments

        Activity

          People

            Unassigned Unassigned
            konrad.oboza@ibexa.co Konrad Oboza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: