LastDragon-ru / lara-asp

Awesome Set of Packages for Laravel
MIT License
11 stars 1 forks source link

It seem auto generated type not recognized relation #135

Closed namttdh closed 8 months ago

namttdh commented 9 months ago

This our my query

extend type Query {
    getOrders(where: _ @searchBy): [Order]! @paginate
}

Order type

type Order {
    "Unique primary key."
    id: ID!

    code: String

    status: OrderStatusConst

    payment_method: String

    user: User @belongsTo

    orderBill: OrderBill @hasOne

    shop: Shop @belongsTo

    orderShip: OrderShip @hasOne

    orderItems: [OrderItem] @hasMany

    orderHistories: [OrderHistory] @hasMany

    shippingCarrier: ShippingCarrier @hasOne
}

enum OrderStatusConst {
    PENDING
    PROCESSING
    SHIPPING
    DELIVERED
    CANCELED
}

Generate type image

=> It seem missing relation type, i don't know why, could you check it?

namttdh commented 9 months ago

Hmm, maybe we need add RelationDirective::class in the config file?

'builder'   => [
        /**
         * The list of the directives which should be copied from the original
         * field into the generated `input` field. All other directives except
         * {@see Operator} will be ignored.
         *
         * The `instanceof` operator is used to check.
         */
        'allowed_directives' => [
            RenameDirective::class,
            + Nuwave\Lighthouse\Schema\Directives\RelationDirective::class,
        ],
    ],

Added and it work like a champp.

LastDragon-ru commented 9 months ago

It seem missing relation type, i don't know why, could you check it?

This is known issue in v5, it should be fixed in main (v6; #114). So maybe you can try it? (see also Upgrade Guide)

Added and it work like a champp.

Please note that it will not work in main (v6). Another way

user: User @belongsTo @searchByOperatorRelation
namttdh commented 9 months ago

It really really hard code for this way..

user: User @belongsTo @searchByOperatorRelation

I think i'll update to dev-main to test it.

Btw, i'm also seeking for schema generation from model PHPDocs, try define both Eloquent Model and graphql type kinda bored...

namttdh commented 9 months ago

Dont understand why can't install dev-main

 docker run --rm --pull=always \
    -v "$(pwd)":/opt \
    -w /opt \
    laravelsail/php82-composer:latest \
    bash -c "composer require lastdragon-ru/lara-asp-graphql dev-main"
latest: Pulling from laravelsail/php82-composer
Digest: sha256:37549f980be6146efcb16b0dc352644edfc5cca32b9862494631eb197ef89737
Status: Image is up to date for laravelsail/php82-composer:latest
./composer.json has been updated
Running composer update lastdragon-ru/lara-asp-graphql
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires lastdragon-ru/lara-asp-graphql dev-main -> satisfiable by lastdragon-ru/lara-asp-graphql[dev-main].
    - lastdragon-ru/lara-asp-graphql dev-main requires lastdragon-ru/lara-asp-core dev-main -> found lastdragon-ru/lara-asp-core[dev-main] but it does not match your minimum-stability.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

I think i'll try later

LastDragon-ru commented 9 months ago

Probably you need to set "minimum-stability": "dev" in your composer.json.

LastDragon-ru commented 9 months ago

Meanwhile the v6 is released 🎉

LastDragon-ru commented 8 months ago

I hope the issue is not actual in v6, so will close this :)