solspace / craft-calendar

Calendar for Craft: The most reliable and powerful event management plugin for Craft.
http://docs.solspace.com/craft/calendar/v5
Other
15 stars 16 forks source link

GraphQL : `relatedToAll`/`relatedToEntries` etc. erroring with `Setting unknown property: Solspace\\Calendar\\Elements\\Db\\EventQuery::XXX` #156

Closed denisyilmaz closed 2 years ago

denisyilmaz commented 2 years ago

When querying for multiple relationships its currently not possible to use relatedToAll in the GQL query:

{
  solspace_calendar {
    calendar {
      id
      __typename
      events(relatedToAll: [186,5], siteId: [3]) {
        id
        title
        count
      }
    }
  }
}

Error

{
  "errors": [
    {
      "debugMessage": "Setting unknown property: Solspace\\Calendar\\Elements\\Db\\EventQuery::relatedToAll",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 574,
          "call": "yii\\base\\Component::__set('relatedToAll', array(2))"
        },
        {
          "file": "/var/www/html/vendor/symfony/property-access/PropertyAccessor.php",
          "line": 582,
          "call": "craft\\elements\\db\\ElementQuery::__set('relatedToAll', array(2))"
        },
        {
          "file": "/var/www/html/vendor/symfony/property-access/PropertyAccessor.php",
          "line": 175,
          "call": "Symfony\\Component\\PropertyAccess\\PropertyAccessor::writeProperty(array(1), 'relatedToAll', array(2))"
        },
        {
          "file": "/var/www/html/vendor/solspace/craft3-calendar/packages/plugin/src/Elements/Event.php",
          "line": 227,
          "call": "Symfony\\Component\\PropertyAccess\\PropertyAccessor::setValue(instance of Solspace\\Calendar\\Elements\\Db\\EventQuery(77), 'relatedToAll', array(2))"
        },
        {
          "file": "/var/www/html/vendor/solspace/craft3-calendar/packages/plugin/src/Services/EventsService.php",
          "line": 108,
          "call": "Solspace\\Calendar\\Elements\\Event::buildQuery(array(4))"
        },
        {
          "file": "/var/www/html/vendor/solspace/craft3-calendar/packages/plugin/src/Bundles/GraphQL/Resolvers/EventResolver.php",
          "line": 25,
          "call": "Solspace\\Calendar\\Services\\EventsService::getEventQuery(array(4))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "Solspace\\Calendar\\Bundles\\GraphQL\\Resolvers\\EventResolver::resolve(instance of Solspace\\Calendar\\Models\\CalendarModel, array(4), array(2), instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, 'Solspace\\Calendar\\Bundles\\GraphQL\\Resolvers\\EventResolver::resolve', instance of Solspace\\Calendar\\Models\\CalendarModel, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: CalendarType, instance of Solspace\\Calendar\\Models\\CalendarModel, instance of ArrayObject(1), array(3))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: CalendarType, instance of Solspace\\Calendar\\Models\\CalendarModel, array(2), instance of ArrayObject(3))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1106,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: CalendarType, instance of ArrayObject(1), array(2), instance of Solspace\\Calendar\\Models\\CalendarModel)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 974,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: CalendarType, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of Solspace\\Calendar\\Models\\CalendarModel)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 789,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: CalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of Solspace\\Calendar\\Models\\CalendarModel)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: CalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of Solspace\\Calendar\\Models\\CalendarModel)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 557,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: CalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(2), instance of Solspace\\Calendar\\Models\\CalendarModel)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: SolspaceCalendarType, instance of stdClass, instance of ArrayObject(1), array(2))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: SolspaceCalendarType, instance of stdClass, array(1), instance of ArrayObject(1))"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1106,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: SolspaceCalendarType, instance of ArrayObject(1), array(1), instance of stdClass)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 974,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: SolspaceCalendarType, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of stdClass)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 789,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeAbstractValue(GraphQLType: SolspaceCalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of stdClass)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: SolspaceCalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of stdClass)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 557,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: SolspaceCalendarInterface, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of stdClass)"
        },
        {
          "file": "/var/www/html/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/html/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/html/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/html/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "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), array(2), null, null)"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Type\\Schema, '{\n  solspace_calendar {\n    calendar {\n      id\n      __typename\n      events(relatedToAll: [186,5], siteId: [3]) {\n        id\n        title\n        count\n      }\n    }\n  }\n}\n', null, array(2), array(2), null, null, array(26))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Gql.php",
          "line": 546,
          "call": "GraphQL\\GraphQL::executeQuery(instance of GraphQL\\Type\\Schema, '{\n  solspace_calendar {\n    calendar {\n      id\n      __typename\n      events(relatedToAll: [186,5], siteId: [3]) {\n        id\n        title\n        count\n      }\n    }\n  }\n}\n', null, array(2), array(2), null, null, array(26))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 172,
          "call": "craft\\services\\Gql::executeQuery(instance of craft\\models\\GqlSchema, '{\n  solspace_calendar {\n    calendar {\n      id\n      __typename\n      events(relatedToAll: [186,5], siteId: [3]) {\n        id\n        title\n        count\n      }\n    }\n  }\n}\n', array(2), null, true)"
        },
        {
          "call": "craft\\controllers\\GraphqlController::actionApi()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array(array(2), array(0))"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "call": "yii\\base\\InlineAction::runWithParams(array(1))"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "call": "yii\\base\\Controller::runAction('api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 293,
          "call": "yii\\base\\Module::runAction('graphql/api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 602,
          "call": "craft\\web\\Application::runAction('graphql/api', array(1))"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 272,
          "call": "craft\\web\\Application::_processActionRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "call": "craft\\web\\Application::handleRequest(instance of craft\\web\\Request)"
        },
        {
          "file": "/var/www/html/web/index.php",
          "line": 27,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ],
denisyilmaz commented 2 years ago

I found out it is possible to query for multiple entries with relatedTo: ["and", 186, 5], so it would be great that relatedToAll and the other relationship arguments are not allowed in the graphql schema to avoid confusion.