thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
557 stars 98 forks source link

substr() expects parameter 1 to be string, int given #172

Closed oojacoboo closed 4 years ago

oojacoboo commented 4 years ago

Version: 4 (50fb4dfd432a2290e08cc6ecde29ee83f7794912)

When executing a GET request to the /graphql endpoint, I'm getting this error:

substr() expects parameter 1 to be string, int given thecodingmachine/graphqlite/src/Utils/NamespacedCache.php:106

The full stack is a long one, included below. I should clarify that the value it's complaining about is zero, 0.

Any thoughts?

{
  "trace": [
    {
      "file": "/.../.../.../api.php",
      "line": 34,
      "function": "run",
      "class": "Zend\\HttpHandlerRunner\\RequestHandlerRunner",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/zendframework/zend-httphandlerrunner/src/RequestHandlerRunner.php",
      "line": 95,
      "function": "handle",
      "class": "xxxx\\Cog\\GraphQL\\Request\\Handler",
      "type": "->",
      "args": [
        {}
      ]
    },
    {
      "file": "/srv/www/src/xxxx/Cog/GraphQL/Request/Handler.php",
      "line": 46,
      "function": "handle",
      "class": "Zend\\Stratigility\\MiddlewarePipe",
      "type": "->",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php",
      "line": 72,
      "function": "process",
      "class": "Zend\\Stratigility\\MiddlewarePipe",
      "type": "->",
      "args": [
        "*** RECURSION ***",
        {}
      ]
    },
    {
      "file": "/srv/www/vendor/zendframework/zend-stratigility/src/MiddlewarePipe.php",
      "line": 83,
      "function": "handle",
      "class": "Zend\\Stratigility\\Next",
      "type": "->",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/zendframework/zend-stratigility/src/Next.php",
      "line": 60,
      "function": "process",
      "class": "TheCodingMachine\\GraphQLite\\Http\\WebonyxGraphqlMiddleware",
      "type": "->",
      "args": [
        "*** RECURSION ***",
        {}
      ]
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/Http/WebonyxGraphqlMiddleware.php",
      "line": 94,
      "function": "executePsrRequest",
      "class": "GraphQL\\Server\\StandardServer",
      "type": "->",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
      "line": 170,
      "function": "executeRequest",
      "class": "GraphQL\\Server\\StandardServer",
      "type": "->",
      "args": [
        {
          "queryId": null,
          "query": "{ hello(name: Jacob)}",
          "operation": null,
          "variables": null,
          "extensions": null
        }
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
      "line": 135,
      "function": "executeOperation",
      "class": "GraphQL\\Server\\Helper",
      "type": "->",
      "args": [
        {},
        "*** RECURSION ***"
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Server/Helper.php",
      "line": 202,
      "function": "promiseToExecuteOperation",
      "class": "GraphQL\\Server\\Helper",
      "type": "->",
      "args": [
        {},
        "*** RECURSION ***",
        "*** RECURSION ***"
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Server/Helper.php",
      "line": 295,
      "function": "promiseToExecute",
      "class": "GraphQL\\GraphQL",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        {
          "extensionASTNodes": null
        },
        {
          "kind": "Document",
          "definitions": "*** NO CLUE - CLOSURE? ***",
          "loc": {
            "start": 0,
            "end": 21,
            "startToken": {
              "kind": "<SOF>",
              "start": 0,
              "end": 0,
              "line": 0,
              "column": 0,
              "value": null,
              "prev": null,
              "next": {
                "kind": "{",
                "start": 0,
                "end": 1,
                "line": 1,
                "column": 1,
                "value": null,
                "prev": "*** RECURSION ***",
                "next": {
                  "kind": "Name",
                  "start": 2,
                  "end": 7,
                  "line": 1,
                  "column": 3,
                  "value": "hello",
                  "prev": "*** RECURSION ***",
                  "next": {
                    "kind": "(",
                    "start": 7,
                    "end": 8,
                    "line": 1,
                    "column": 8,
                    "value": null,
                    "prev": "*** RECURSION ***",
                    "next": {
                      "kind": "Name",
                      "start": 8,
                      "end": 12,
                      "line": 1,
                      "column": 9,
                      "value": "name",
                      "prev": "*** RECURSION ***",
                      "next": {
                        "kind": ":",
                        "start": 12,
                        "end": 13,
                        "line": 1,
                        "column": 13,
                        "value": null,
                        "prev": "*** RECURSION ***",
                        "next": {
                          "kind": "Name",
                          "start": 14,
                          "end": 19,
                          "line": 1,
                          "column": 15,
                          "value": "Jacob",
                          "prev": "*** RECURSION ***",
                          "next": {
                            "kind": ")",
                            "start": 19,
                            "end": 20,
                            "line": 1,
                            "column": 20,
                            "value": null,
                            "prev": "*** RECURSION ***",
                            "next": {
                              "kind": "}",
                              "start": 20,
                              "end": 21,
                              "line": 1,
                              "column": 21,
                              "value": null,
                              "prev": "*** RECURSION ***",
                              "next": {
                                "kind": "<EOF>",
                                "start": 21,
                                "end": 21,
                                "line": 1,
                                "column": 22,
                                "value": null,
                                "prev": "*** RECURSION ***",
                                "next": null
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            },
            "endToken": "*** RECURSION ***",
            "source": {
              "body": "{ hello(name: Jacob)}",
              "length": 21,
              "name": "GraphQL request",
              "locationOffset": {
                "line": 1,
                "column": 1
              }
            }
          }
        },
        null,
        {},
        null,
        null,
        null,
        null
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/GraphQL.php",
      "line": 149,
      "function": "validate",
      "class": "GraphQL\\Validator\\DocumentValidator",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        "*** RECURSION ***",
        {
          "GraphQL\\Validator\\Rules\\ExecutableDefinitions": {},
          "GraphQL\\Validator\\Rules\\UniqueOperationNames": {
            "knownOperationNames": []
          },
          "GraphQL\\Validator\\Rules\\LoneAnonymousOperation": {},
          "GraphQL\\Validator\\Rules\\KnownTypeNames": {},
          "GraphQL\\Validator\\Rules\\FragmentsOnCompositeTypes": {},
          "GraphQL\\Validator\\Rules\\VariablesAreInputTypes": {},
          "GraphQL\\Validator\\Rules\\ScalarLeafs": {},
          "GraphQL\\Validator\\Rules\\FieldsOnCorrectType": {},
          "GraphQL\\Validator\\Rules\\UniqueFragmentNames": {
            "knownFragmentNames": []
          },
          "GraphQL\\Validator\\Rules\\KnownFragmentNames": {},
          "GraphQL\\Validator\\Rules\\NoUnusedFragments": {
            "operationDefs": [
              {
                "kind": "OperationDefinition",
                "name": null,
                "operation": "query",
                "variableDefinitions": "*** NO CLUE - CLOSURE? ***",
                "directives": "*** NO CLUE - CLOSURE? ***",
                "selectionSet": {
                  "kind": "SelectionSet",
                  "selections": "*** NO CLUE - CLOSURE? ***",
                  "loc": {
                    "start": 0,
                    "end": 21,
                    "startToken": "*** RECURSION ***",
                    "endToken": "*** RECURSION ***",
                    "source": "*** RECURSION ***"
                  }
                },
                "loc": {
                  "start": 0,
                  "end": 21,
                  "startToken": "*** RECURSION ***",
                  "endToken": "*** RECURSION ***",
                  "source": "*** RECURSION ***"
                }
              }
            ],
            "fragmentDefs": []
          },
          "GraphQL\\Validator\\Rules\\PossibleFragmentSpreads": {},
          "GraphQL\\Validator\\Rules\\NoFragmentCycles": {
            "visitedFrags": [],
            "spreadPath": [],
            "spreadPathIndexByName": []
          },
          "GraphQL\\Validator\\Rules\\UniqueVariableNames": {
            "knownVariableNames": []
          },
          "GraphQL\\Validator\\Rules\\NoUndefinedVariables": {},
          "GraphQL\\Validator\\Rules\\NoUnusedVariables": {
            "variableDefs": []
          },
          "GraphQL\\Validator\\Rules\\KnownDirectives": {},
          "GraphQL\\Validator\\Rules\\UniqueDirectivesPerLocation": {},
          "GraphQL\\Validator\\Rules\\KnownArgumentNames": {},
          "GraphQL\\Validator\\Rules\\UniqueArgumentNames": {
            "knownArgNames": []
          },
          "GraphQL\\Validator\\Rules\\ValuesOfCorrectType": {},
          "GraphQL\\Validator\\Rules\\ProvidedNonNullArguments": {},
          "GraphQL\\Validator\\Rules\\VariablesDefaultValueAllowed": {},
          "GraphQL\\Validator\\Rules\\VariablesInAllowedPosition": {
            "varDefMap": []
          },
          "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged": {},
          "GraphQL\\Validator\\Rules\\UniqueInputFieldNames": {
            "knownNames": [],
            "knownNameStack": []
          },
          "GraphQL\\Validator\\Rules\\DisableIntrospection": {},
          "GraphQL\\Validator\\Rules\\QueryDepth": {},
          "GraphQL\\Validator\\Rules\\QueryComplexity": {}
        }
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
      "line": 118,
      "function": "visitUsingRules",
      "class": "GraphQL\\Validator\\DocumentValidator",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        {},
        "*** RECURSION ***",
        "*** RECURSION ***"
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/DocumentValidator.php",
      "line": 226,
      "function": "visit",
      "class": "GraphQL\\Language\\Visitor",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        {
          "enter": {},
          "leave": {}
        }
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Language/Visitor.php",
      "line": 273,
      "function": "GraphQL\\Language\\{closure}",
      "class": "GraphQL\\Language\\Visitor",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        "selectionSet",
        "*** RECURSION ***",
        [
          "definitions",
          0,
          "selectionSet"
        ],
        [
          "*** RECURSION ***",
          "*** RECURSION ***"
        ]
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Language/Visitor.php",
      "line": 466,
      "function": "GraphQL\\Language\\{closure}",
      "class": "GraphQL\\Language\\Visitor",
      "type": "::",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Language/Visitor.php",
      "line": 410,
      "function": "GraphQL\\Validator\\Rules\\{closure}",
      "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged",
      "type": "->",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php",
      "line": 65,
      "function": "findConflictsWithinSelectionSet",
      "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged",
      "type": "->",
      "args": [
        {},
        "Query",
        "*** RECURSION ***"
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php",
      "line": 97,
      "function": "getFieldsAndFragmentNames",
      "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged",
      "type": "->",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php",
      "line": 166,
      "function": "internalCollectFieldsAndFragmentNames",
      "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged",
      "type": "->",
      "args": [
        "*** RECURSION ***",
        "*** RECURSION ***",
        "*** RECURSION ***",
        [],
        []
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Validator/Rules/OverlappingFieldsCanBeMerged.php",
      "line": 255,
      "function": "getFields",
      "class": "GraphQL\\Type\\Definition\\ObjectType",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Type/Definition/ObjectType.php",
      "line": 151,
      "function": "defineFieldMap",
      "class": "GraphQL\\Type\\Definition\\FieldDefinition",
      "type": "::",
      "args": [
        "*** RECURSION ***",
        "*** RECURSION ***"
      ]
    },
    {
      "file": "/srv/www/vendor/webonyx/graphql-php/src/Type/Definition/FieldDefinition.php",
      "line": 90,
      "function": "TheCodingMachine\\GraphQLite\\{closure}",
      "class": "TheCodingMachine\\GraphQLite\\Schema",
      "type": "::",
      "args": []
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/Schema.php",
      "line": 36,
      "function": "getQueries",
      "class": "TheCodingMachine\\GraphQLite\\AggregateQueryProvider",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/AggregateQueryProvider.php",
      "line": 35,
      "function": "array_map",
      "args": [
        {},
        [
          {}
        ]
      ]
    },
    {
      "function": "TheCodingMachine\\GraphQLite\\{closure}",
      "class": "TheCodingMachine\\GraphQLite\\AggregateQueryProvider",
      "type": "::",
      "args": "*** RECURSION ***"
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/AggregateQueryProvider.php",
      "line": 34,
      "function": "getQueries",
      "class": "TheCodingMachine\\GraphQLite\\GlobControllerQueryProvider",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/GlobControllerQueryProvider.php",
      "line": 121,
      "function": "getAggregateControllerQueryProvider",
      "class": "TheCodingMachine\\GraphQLite\\GlobControllerQueryProvider",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/GlobControllerQueryProvider.php",
      "line": 68,
      "function": "getInstancesList",
      "class": "TheCodingMachine\\GraphQLite\\GlobControllerQueryProvider",
      "type": "->",
      "args": []
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/GlobControllerQueryProvider.php",
      "line": 84,
      "function": "get",
      "class": "Symfony\\Component\\Cache\\Adapter\\AbstractAdapter",
      "type": "->",
      "args": [
        "globQueryProvider",
        {}
      ]
    },
    {
      "file": "/srv/www/vendor/symfony/cache-contracts/CacheTrait.php",
      "line": 30,
      "function": "doGet",
      "class": "Symfony\\Component\\Cache\\Adapter\\AbstractAdapter",
      "type": "->",
      "args": [
        {},
        "globQueryProvider",
        "*** RECURSION ***",
        1,
        null
      ]
    },
    {
      "file": "/srv/www/vendor/symfony/cache/Traits/ContractsTrait.php",
      "line": 95,
      "function": "doGet",
      "class": "Symfony\\Component\\Cache\\Adapter\\AbstractAdapter",
      "type": "->",
      "args": [
        "*** RECURSION ***",
        "globQueryProvider",
        {},
        1,
        null,
        null
      ]
    },
    {
      "file": "/srv/www/vendor/symfony/cache-contracts/CacheTrait.php",
      "line": 48,
      "function": "getItem",
      "class": "Symfony\\Component\\Cache\\Adapter\\AbstractAdapter",
      "type": "->",
      "args": [
        "globQueryProvider"
      ]
    },
    {
      "file": "/srv/www/vendor/symfony/cache/Traits/AbstractAdapterTrait.php",
      "line": 51,
      "function": "doFetch",
      "class": "Symfony\\Component\\Cache\\Adapter\\Psr16Adapter",
      "type": "->",
      "args": [
        [
          "xxxx_Controller_globQueryProvider"
        ]
      ]
    },
    {
      "file": "/srv/www/vendor/symfony/cache/Adapter/Psr16Adapter.php",
      "line": 48,
      "function": "getMultiple",
      "class": "TheCodingMachine\\GraphQLite\\Utils\\NamespacedCache",
      "type": "->",
      "args": [
        "*** RECURSION ***",
        {}
      ]
    },
    {
      "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/Utils/NamespacedCache.php",
      "line": 106,
      "function": "substr",
      "args": [
        0,
        8
      ]
    }
  ],
  "message": "substr() expects parameter 1 to be string, int given",
  "file": "/srv/www/vendor/thecodingmachine/graphqlite/src/Utils/NamespacedCache.php",
  "line": 106,
  "class": "TypeError",
oojacoboo commented 4 years ago

So, it turns out that the caching layer was returning a 0 index in the results which didn't match the expected string key. Not really an issue with the library.