V8-archive: GraphQL query always return NotFound

Created on 8 Jul 2019  Â·  13Comments  Â·  Source: directus/v8-archive

Bug Report

Steps to Reproduce

  1. Start a single API instance
  2. Create some collection
  3. Add static token to the database for the admin user
  4. Use GraphiQL

Set the URL something like: http://127.0.0.1:7000/_/gql?access_token=example and make a query to previous create content, for example:

{
  test(limit:10) { data { status } }
}

Put query before doesn't change the result, the API server always return:

{"error":{"code":1,"message":"Not Found"}}

Expected Behavior

The GraphQL query to succeed

Actual Behavior

Always return 404.

Technical Details

Get site root: / return:

{
    "data": {
        "api": {
            "version": "2.0.18"
        },
        "server": {
            "general": {
                "php_api": "fpm-fcgi",
                "php_version": "7.2.13"
            },
            "max_upload_size": 2097152
        }
    }
}
bug docker

All 13 comments

@Bedotech can you please provide the logs? You can find me @hem on directus.chat

No log is present, I running dockerized copy of the application, there is no error in the log, it seems cannot recognize the static token, because if I change it to a meaningless value it always returns 404 instead of 403

Hello,
some more info about this.

it seems that launching any GraphQL query on master always returns this error:

{"error":{"code":4,"message":"collection: This value should not be blank."}}

The same query works in the graphql branch, so it's probably a conflict with another recent change.

Here is the stack trace:

[2019-07-09 10:43:15] api[_].ERROR: Directus\Validator\Exception\InvalidRequestException: collection: This value should not be blank. in /var/www/html/src/core/Directus/Services/AbstractService.php:190
Stack trace:
#0 /var/www/html/src/core/Directus/Services/AbstractService.php(120): Directus\Services\AbstractService->throwErrorIfAny
#1 /var/www/html/src/core/Directus/Services/TablesService.php(80): Directus\Services\AbstractService->validate
#2 /var/www/html/src/core/Directus/GraphQL/FieldsConfig.php(23): Directus\Services\TablesService->findAllFieldsByCollection
#3 /var/www/html/src/core/Directus/GraphQL/Type/FieldsType.php(14): Directus\GraphQL\FieldsConfig->__construct
#4 /var/www/html/src/core/Directus/GraphQL/Types.php(156): Directus\GraphQL\Type\FieldsType->__construct
#5 /var/www/html/src/core/Directus/GraphQL/FieldsConfig.php(89): Directus\GraphQL\Types::userCollection
#6 /var/www/html/src/core/Directus/GraphQL/Type/FieldsType.php(18): Directus\GraphQL\FieldsConfig->getFields
#7 /var/www/html/vendor/webonyx/graphql-php/src/Type/Definition/FieldDefinition.php(90): Directus\GraphQL\Type\FieldsType->Directus\GraphQL\Type\{closure}
#8 /var/www/html/vendor/webonyx/graphql-php/src/Type/Definition/ObjectType.php(151): GraphQL\Type\Definition\FieldDefinition::defineFieldMap
#9 /var/www/html/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(180): GraphQL\Type\Definition\ObjectType->getFields
#10 /var/www/html/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(142): GraphQL\Utils\TypeInfo::extractTypes
#11 /var/www/html/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(200): GraphQL\Utils\TypeInfo::extractTypes
#12 /var/www/html/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php(200): GraphQL\Utils\TypeInfo::extractTypes
#13 /var/www/html/vendor/webonyx/graphql-php/src/Type/Schema.php(213): GraphQL\Utils\TypeInfo::extractTypes
#14 /var/www/html/vendor/webonyx/graphql-php/src/Type/Schema.php(199): GraphQL\Type\Schema->collectAllTypes
#15 /var/www/html/vendor/webonyx/graphql-php/src/Type/Schema.php(153): GraphQL\Type\Schema->getTypeMap
#16 /var/www/html/src/core/Directus/Services/GraphQLService.php(16): GraphQL\Type\Schema->__construct
#17 /var/www/html/src/endpoints/GraphQL.php(33): Directus\Services\GraphQLService->index
#18 [internal function]: Directus\Api\Routes\GraphQL->index
#19 /var/www/html/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func
#20 /var/www/html/vendor/slim/slim/Slim/Route.php(356): Slim\Handlers\Strategies\RequestResponse->__invoke
#21 /var/www/html/src/core/Directus/Application/Http/Middleware/AdminOnlyMiddleware.php(19): Slim\Route->__invoke
#22 [internal function]: Directus\Application\Http\Middleware\AdminOnlyMiddleware->__invoke
#23 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#24 [internal function]: Slim\DeferredCallable->__invoke
#25 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#26 /var/www/html/src/core/Directus/Application/Http/Middleware/AbstractRateLimitMiddleware.php(34): Slim\Route->Slim\{closure}
#27 [internal function]: Directus\Application\Http\Middleware\AbstractRateLimitMiddleware->__invoke
#28 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#29 [internal function]: Slim\DeferredCallable->__invoke
#30 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#31 /var/www/html/src/core/Directus/Application/Http/Middleware/AuthenticationMiddleware.php(81): Slim\Route->Slim\{closure}
#32 [internal function]: Directus\Application\Http\Middleware\AuthenticationMiddleware->__invoke
#33 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#34 [internal function]: Slim\DeferredCallable->__invoke
#35 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#36 /var/www/html/src/core/Directus/Application/Http/Middleware/TableGatewayMiddleware.php(25): Slim\Route->Slim\{closure}
#37 [internal function]: Directus\Application\Http\Middleware\TableGatewayMiddleware->__invoke
#38 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#39 [internal function]: Slim\DeferredCallable->__invoke
#40 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#41 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->Slim\{closure}
#42 /var/www/html/vendor/slim/slim/Slim/Route.php(334): Slim\Route->callMiddlewareStack
#43 /var/www/html/vendor/slim/slim/Slim/App.php(515): Slim\Route->run
#44 /var/www/html/src/core/Directus/Application/Http/Middleware/AbstractRateLimitMiddleware.php(34): Slim\App->__invoke
#45 [internal function]: Directus\Application\Http\Middleware\AbstractRateLimitMiddleware->__invoke
#46 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#47 [internal function]: Slim\DeferredCallable->__invoke
#48 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#49 /var/www/html/vendor/directus/proxy-detection/src/ProxyDetectionMiddleware.php(30): Slim\App->Slim\{closure}
#50 /var/www/html/src/core/Directus/Application/Http/Middleware/ProxyMiddleware.php(18): RKA\Middleware\ProxyDetectionMiddleware->__invoke
#51 [internal function]: Directus\Application\Http\Middleware\ProxyMiddleware->__invoke
#52 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#53 [internal function]: Slim\DeferredCallable->__invoke
#54 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#55 /var/www/html/vendor/akrabat/ip-address-middleware/src/IpAddress.php(113): Slim\App->Slim\{closure}
#56 [internal function]: RKA\Middleware\IpAddress->__invoke
#57 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#58 [internal function]: Slim\DeferredCallable->__invoke
#59 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#60 /var/www/html/src/core/Directus/Application/Http/Middleware/CorsMiddleware.php(66): Slim\App->Slim\{closure}
#61 [internal function]: Directus\Application\Http\Middleware\CorsMiddleware->__invoke
#62 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#63 [internal function]: Slim\DeferredCallable->__invoke
#64 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#65 /var/www/html/src/core/Directus/Application/Http/Middleware/ResponseCacheMiddleware.php(47): Slim\App->Slim\{closure}
#66 [internal function]: Directus\Application\Http\Middleware\ResponseCacheMiddleware->__invoke
#67 /var/www/html/vendor/slim/slim/Slim/DeferredCallable.php(43): call_user_func_array
#68 [internal function]: Slim\DeferredCallable->__invoke
#69 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func
#70 /var/www/html/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->Slim\{closure}
#71 /var/www/html/vendor/slim/slim/Slim/App.php(405): Slim\App->callMiddlewareStack
#72 /var/www/html/vendor/slim/slim/Slim/App.php(313): Slim\App->process
#73 /var/www/html/src/core/Directus/Application/Application.php(161): Slim\App->run
#74 /var/www/html/public/index.php(5): Directus\Application\Application->run [] []

Hi @ale-rinaldi The error you are getting is REST api error code. So I think there is something wrong with your collection.

What installation method you are using?

if possible, please give your DB dump over slack. You can find me @Hem on directus.chat

Hello @hemratna ,
you're right, there was actually some mess in the relations, that made the getRelation() call to return an empty array. So, $relation['collection_many'] was undefined and that made the rest.

Thanks again!

I am glad that you figure out the issue.

I am curious how you messed up with relations?
If you using the Directus App and you perform certain steps which result in your mess, then please let me know.

Via App is little tricky setup translation field inside a content type but if you misconfigured the relation in the Relation configuration tab for the field no error is reported, for example, bound to another translation collection on another foreign key, like here:

wrong_translation_relation

As you can see above the content section must have relations to section_translation and not to box_translation, it is a logical error from our side, but I don't know why this break all on GraphQL side.

GraphQL schema is generated from relationship define the directus_collections, directus_fields, and directus_relations
So any misconfiguration will result in the invalid whole schema.

Ok we can close

Hum... I'm suffering the same issue, but I have no problems (apparently) on my relations.
They are correct and I can query them correctly via rest.
However, with graphql, always returns the exact same error as the top of this thread.
Any ideas?

@urbgimtam — I assume you're on the latest version and updated the database, etc?

@hemratna — any ideas?

Hi @urbgimtam

Are you using the Docker?
if possible, please give your DB dump over slack. You can find me @Hem on directus.chat

HI @benhaynes and @hemratna.

I'm on the latest version and updated db, yes.
I do have some relations, but they work correctly both on the cms and on rest.

@hemratna I'll find you on the chat and send you my db.
Thanks for the assistance :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Varulv1997 picture Varulv1997  Â·  3Comments

magikstm picture magikstm  Â·  3Comments

ondronix picture ondronix  Â·  3Comments

HashemKhalifa picture HashemKhalifa  Â·  3Comments

gitlabisbetterthangithub picture gitlabisbetterthangithub  Â·  3Comments