Lighthouse: "debugMessage": "No class 'Profile' was found for directive 'update'",

Created on 27 Jul 2019  路  7Comments  路  Source: nuwave/lighthouse

Describe the bug
I'm using laravel 5.8 Now After update 5.7 to 5.8 I'm getting an error

Expected behavior/Solution

Steps to reproduce

1.
type Query {

    users: [User!]! @paginate(type: "paginator" model: "App\\User")
    user(id: ID @eq): User @find(model: "App\\User")

    profiles: [Profile] @all
    me(id: ID @eq): Profile @find(model: "App\\Profile\\Profile")

}
type Mutation {

  updateProfile(
      id: ID!,
      bio: String

      ): Profile @update

}
type User {
    id: ID!
    name: String!
    email: String!
    created_at: DateTime!
    updated_at: DateTime!
    profile: Profile @hasOne
}
type Profile{
    id: ID!
    bio: String!
    dob: String!
}

Output/Logs

Click to expand

# Add in log output/error messages here

{
"debugMessage": "No class 'Profile' was found for directive 'update'",
"message": "Internal server error",
"extensions": {
"category": "schema"
},
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"updateProfile"
],
"trace": [
{
"file": "C:\Users\Dimer\final\laravel-vue-spa\vendor\nuwave\lighthouse\src\Schema\Directives\BaseDirective.php",
"line": 210,
"call": "Nuwave\Lighthouse\Schema\Directives\BaseDirective::namespaceClassName('Profile', array(2), instance of Closure)"


Environment

Lighthouse Version:
Laravel Version: 5.8

question

Most helpful comment

Are additional namespaces listed for models in config/lighthouse.php?
image

All 7 comments

How is your Profile model? Are your sure that his namespace is App\Profile ? Please show some code.

Are additional namespaces listed for models in config/lighthouse.php?
image

Quick question: Is it a good practice to use vuex + vue-apollo

Thank you for opening my eyes

I change this
' models' => 'App\\Models' to ' models' => 'App'
It work fine

___________________Changes______________________________
config/lighthouse.php

 'namespaces' => [
        'models' => 'App',
        'queries' => 'App\\GraphQL\\Queries',
        'mutations' => 'App\\GraphQL\\Mutations',
        'subscriptions' => 'App\\GraphQL\\Subscriptions',
        'interfaces' => 'App\\GraphQL\\Interfaces',
        'unions' => 'App\\GraphQL\\Unions',
        'scalars' => 'App\\GraphQL\\Scalars',
        'directives' => ['App\\GraphQL\\Directives'],
    ],

How is your Profile model? Are your sure that his namespace is App\Profile ? Please show some code.

Thank you for your reply .

I change this
' models' => 'App\\Models'to' models' => 'App'
It work fine

_Changes_
config/lighthouse.php

I use vuex with apollo, I think it is fine.

However, following with your issue, your schema is:

me(id: ID @eq): Profile @find(model: "App\\Profile\\Profile")

So you are expliciting the namespace of your model. If it doesn't exist, it tries to find it with one of those namespaces that you can configure in config/lighthouse.php, as MrDreek said.

BUT, if you will configure a common namespace for all your models, you could write your schema like:

me(id: ID @eq): Profile @find

it auto-detects that you are looking for the Profile model, and, according to the config, it can also auto-find it.

Sounds like your issue has been resolved, if I am wrong please reopen or comment about it.

Sounds like your issue has been resolved, if I am wrong please reopen or comment about it.

No. you're not thank you. issue resolved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spawnia picture spawnia  路  4Comments

spawnia picture spawnia  路  3Comments

caizhigang97 picture caizhigang97  路  3Comments

vine1993 picture vine1993  路  3Comments

m1guelpf picture m1guelpf  路  3Comments