nuwave / lighthouse

A framework for serving GraphQL from Laravel
https://lighthouse-php.com
MIT License
3.35k stars 438 forks source link

No class 'TodoPaginator' was found for directive 'paginate' #1144

Closed MilesWuCode closed 4 years ago

MilesWuCode commented 4 years ago

I have the same problem with that guy

https://stackoverflow.com/questions/59726381/laravel-lighthouse-using-paginate-on-related-models-breaks-ability-to-query-mo

type Todo {
    id: ID!
    title: String
}

type User {
    id: ID!
    name: String
    email: String
    todos: [Todo!]! @hasMany(type: "paginator")
}

type Query{
    todo(id: ID! @eq): Todo @find
    todos: [Todo!]! @paginate
    user(id: ID! @eq): User @find
}

image

image

spawnia commented 4 years ago

Can you provide a PR with a failing test case in https://github.com/nuwave/lighthouse/blob/master/tests/Integration/Schema/Directives/HasManyDirectiveTest.php ?

MilesWuCode commented 4 years ago

Can you provide a PR with a failing test case in https://github.com/nuwave/lighthouse/blob/master/tests/Integration/Schema/Directives/HasManyDirectiveTest.php ?

i try to Tests, @hasMany and @paginate is Ok!

this error when "schema.graphql" use #import , will appear

#import user.graphql
#import todo.graphql

截圖 2020-01-15 下午1 51 58

spawnia commented 4 years ago

#import does nothing but concatinate the schema strings. I don't see how that could be the cause of the bug.

It may however be related to the merging of fields through extend type, can you try adding an example like this to the test file?

MilesWuCode commented 4 years ago

#import does nothing but concatinate the schema strings. I don't see how that could be the cause of the bug.

It may however be related to the merging of fields through extend type, can you try adding an example like this to the test file?

Sorry my test skill only sample php i don't know graphql file how to change #import for test.... so.....this is video url is my process https://drive.google.com/file/d/1FKDkPriDN3F3G3nAPNTBx2QNyQnpQoAN/view?usp=sharing

spawnia commented 4 years ago

Check out our contribution guide for information on how you can run our testsuite: https://github.com/nuwave/lighthouse/blob/master/CONTRIBUTING.md#testing

Add a representative example that matches your test case to https://github.com/nuwave/lighthouse/blob/master/tests/Integration/Schema/Directives/HasManyDirectiveTest.php and try to reproduce the error. You don't have to use #import, just modify the schema in the test class so it matches what you have in your app.

MilesWuCode commented 4 years ago

#import does nothing but concatinate the schema strings. I don't see how that could be the cause of the bug.

You don't have to use #import, just modify the schema in the test class ....

Every code is working NO '#import' is working $this->schema = '.....' can write '#import' ? i don't think so...

spawnia commented 4 years ago

The mechanism behing #import is really simple and well tested. It is really just string concatenation. You can just copy-and-paste the contents of your extracted files directly into schema.graphql, i expect the error to persist.

That is why i think the error might originate from something else, maybe the usage of extend. Just put the whole schema that triggers it in $this->schema.