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

about graphql API issue #626

Closed
marol1210 opened this issue Apr 5, 2022 · 4 comments
Closed

about graphql API issue #626

marol1210 opened this issue Apr 5, 2022 · 4 comments

Comments

@marol1210
Copy link

Describe the bug
avored's graphql api can't find graphql offset of TYPES which config in config/avored.php.

To Reproduce
Steps to reproduce the behavior:

  1. install avored from docker-dev
  2. visiter fontend
  3. show exception

Screenshots

{
  "errors": [
    {
      "debugMessage": "Type Category not found.\nCheck that the config array key for the type matches the name attribute in the type's class.\nIt is required when 'lazyload_types' is enabled",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 2,
          "column": 1
        }
      ],
      "path": [
        "allCategory",
        0
      ],
      "trace": [
        {
          "file": "/var/www/backend/vendor/rebing/graphql-laravel/src/GraphQL.php",
          "line": 224,
          "call": "Rebing\\GraphQL\\GraphQL::getType('Category', false)"
        },
        {
          "file": "/var/www/backend/vendor/rebing/graphql-laravel/src/GraphQL.php",
          "line": 394,
          "call": "Rebing\\GraphQL\\GraphQL::type('Category')"
        },
        omit....

Additional context

  1. config/avored.php content:
        'types' => [
            'category' => CategoryType::class,
            'product' => ProductType::class,
            'customer' => CustomerType::class,
            'order' => OrderType::class,
            'address' => AddressType::class,
            'notification' => NotificationType::class,
            'cartProduct' => CartProductType::class,
            'payment' => PaymentType::class,
            'shipping' => ShippingType::class,
            'subscriber' => SubscriberType::class,
            'option' => OptionType::class,
        ]
  1. property attributes of class CategoryType is
    $attributes = [
        'name' => 'Category',
        'description' => 'A type'
    ]

and
there is space in property attributes of class ShippingType
$attributes = [
'name' => 'Shipping Type',
'description' => 'A type'
]

so under my local environment ,  avored's config about grahpql's TYPES which key is lowercase , but  capitalize in  property attributes 
@indpurvesh
Copy link
Member

@marol1210 Have you manage to fixed it?

@marol1210
Copy link
Author

@marol1210 Have you manage to fixed it?

Yes , despite of fixed , it's not smart. I just modify name value of $attributes in which every AvoRed\\Framework\\Graphql\\Types classes to same as key of config/avored.php TYPES field.

@marol1210
Copy link
Author

marol1210 commented Apr 11, 2022

@marol1210 Have you manage to fixed it?

alternative , just use type name of TYPE from graphql self whatever others. because , under hood, the name is defined by graphql Rebing\GraphQL\GraphQL::addTypes. so just use.

graphql introspection for exmaple:

{
__schema{
  types{
    name
    description
  }
}
}

after

{
  "data": {
    "__schema": {
      "types": [
        {
          "name": "Product",
          "description": "A type"
        },
        {
          "name": "Category",
          "description": "A type"
        }
        ....
 }

@indpurvesh
Copy link
Member

Can you please do a pull request with your fixed.
@marol1210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants