larsroettig-dev / module-graphqlstorepickup

How to create a GraphQL Endpoint for Magento 2.3
https://larsroettig.dev/how-to-create-a-graph-ql-endpoint-for-magento-2-3
MIT License
10 stars 3 forks source link

Getting error while applying GraphQL-Query with a filter #3

Open ParthBrahmbhatt opened 4 years ago

ParthBrahmbhatt commented 4 years ago
query{
  pickUpStores(
    filter: { name: { like: "Brick and Mortar 1%" } }
    pageSize: 2
    currentPage: 1
  ) {
    total_count
    items {
      name
      street
      postcode
    }
  }
}

Below error coming after execute the query mentioned into module

{
  "errors": [
    {
      "debugMessage": "Attribute not found in the visible attributes list",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "pickUpStores"
      ]
    }
  ],
  "data": {
    "pickUpStores": null
  }
}
alexskipper commented 3 years ago

I go stuck on this as well (Magento 2.4). in FilterArgument.php the getEntityAttributes method looks like its returning the wrong type of array which throws an error in Magento's AstConverter.

I fixed it by changing getEntityAttributes() method to:

public function getEntityAttributes(): array { $fields = []; foreach ($this->config->getConfigElement('PromoBanner')->getFields() as $field) { $fields[$field->getName()] = [ 'type' => 'String', 'fieldName' => $this->fieldMapping[$field->getName()] ?? $field->getName(), ]; } return $fields; }