title: GraphQL Query Not Returning Anything From Laravel
body: <p>I'm using the laravel-graphql library from Folklore. I've followed all the instructions to the T, but when I test it out in the Altair Client for Windows, I get "Unknown Server Error, Code 0". My REST API works so it's either that I made an error in setting up the GraphQL layer or Folklore not updating their library has finally fallen behind to the Laravel version that I'm using. It's 5.7.</p>
  
  <p><strong>POSTTYPE.PHP</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\GraphQL\Type;
  
  use GraphQL\Type\Definition\Type;
  use Folklore\GraphQL\Support\Type as GraphQLType;
  
  /* Here we're giving the type a name and description */
  class PostType extends GraphQLType {
      protected $attributes = [
          'name' =&gt; 'Post', //here we're defining the query by giving it a name of Post
          'description' =&gt; 'One post'
      ];
  
      public function fields(){
          return [
              'id' =&gt; [
                  'type' =&gt; Type::nonNull(Type::int()),
                  'description' =&gt; 'Primary key; incrementing id of post'
              ],
              'header' =&gt; [
                  'type' =&gt; Type::string(),
                  'description' =&gt; 'The header of the post'
              ],
              'body' =&gt; [
                  'type' =&gt; Type::string(),
                  'description' =&gt; 'The body of the blog post'
              ],
              'created_at' =&gt; [
                  'type' =&gt; Type::string(),
                  'description' =&gt; 'When the post was created'
              ],
              'updated_at' =&gt; [
                  'type' =&gt; Type::string(),
                  'description' =&gt; 'When the post was last updated'
              ],
              'img' =&gt; [
                  'type' =&gt; Type::string(),
                  'description' =&gt; 'Where the main image of the blog post is stored'
              ],
          ];
      }
  
      // If you want to resolve the field yourself, you can declare a method
      // with the following format resolve[FIELD_NAME]Field()
  
      //protected function resolveEmailField($root, $args)
      //{
      //    return strtolower($root-&gt;email);
      //}
  }
  </code></pre>
  
  <p><strong>POSTQUERY.PHP</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\GraphQL\Query;
  
  use GraphQL;
  use GraphQL\Type\Definition\Type;
  use Folklore\GraphQL\Support\Query;
  use App\Post;
  
  class PostsQuery extends Query {
      //give the query a name of 'posts'
      protected $attributes = [
          'name' =&gt; 'posts' 
      ];
  
      //define the query type
      public function type(){
          return Type::listOf(GraphQL::type('Post'));
      }
  
      //define things to fetch and turn them into arguments
      public function args(){
          return [
              'id' =&gt; ['name' =&gt; 'id', 'type' =&gt; Type::int()],
              'header' =&gt; ['name' =&gt; 'header', 'type' =&gt; Type::string()],
              'body' =&gt; ['name' =&gt; 'body', 'type' =&gt; Type::string()],
              'img' =&gt; ['name' =&gt; 'img', 'type' =&gt; Type::string()],
          ];
      }
  
      //fetch all the posts
      public function resolve($root, $args){
          if (isset($args['id'])){
              return Post::where('id', $args['id'])-&gt;get();
          }
          else if (isset($args['header'])){
              return Post::where('header', $args['header'])-&gt;get();
          }
          else if (isset($args['body'])){
              return Post::where('body', $args['body'])-&gt;get();
          }
          else if (isset($args['img'])){
              return Post::where('img', $args['img'])-&gt;get();
          }
          else {
              return Post::all();
          }
      }
  }
  </code></pre>
  
  <p><strong>CONFIG/GRAPHQL.PHP</strong></p>
  
  <pre><code>&lt;?php
  
  
  return [
  
      // The prefix for routes
      'prefix' =&gt; 'graphql',
  
      // The routes to make GraphQL request. Either a string that will apply
      // to both query and mutation or an array containing the key 'query' and/or
      // 'mutation' with the according Route
      //
      // Example:
      //
      // Same route for both query and mutation
      //
      // 'routes' =&gt; 'path/to/query/{graphql_schema?}',
      //
      // or define each routes
      //
      // 'routes' =&gt; [
      //     'query' =&gt; 'query/{graphql_schema?}',
      //     'mutation' =&gt; 'mutation/{graphql_schema?}'
      // ]
      //
      // you can also disable routes by setting routes to null
      //
      // 'routes' =&gt; null,
      //
      'routes' =&gt; '{graphql_schema?}',
  
      // The controller to use in GraphQL request. Either a string that will apply
      // to both query and mutation or an array containing the key 'query' and/or
      // 'mutation' with the according Controller and method
      //
      // Example:
      //
      // 'controllers' =&gt; [
      //     'query' =&gt; '\Folklore\GraphQL\GraphQLController@query',
      //     'mutation' =&gt; '\Folklore\GraphQL\GraphQLController@mutation'
      // ]
      //
      'controllers' =&gt; '\Folklore\GraphQL\GraphQLController@query',
  
      // Any middleware for the graphql route group
      'middleware' =&gt; [],
  
      // The name of the default schema used when no argument is provided
      // to GraphQL::schema() or when the route is used without the graphql_schema
      // parameter.
      'schema' =&gt; 'default',
  
      // The schemas for query and/or mutation. It expects an array to provide
      // both the 'query' fields and the 'mutation' fields. You can also
      // provide directly an object GraphQL\Schema
      //
      // Example:
      //
      // 'schemas' =&gt; [
      //     'default' =&gt; new Schema($config)
      // ]
      //
      // or
      //
      // 'schemas' =&gt; [
      //     'default' =&gt; [
      //         'query' =&gt; [
      //              'users' =&gt; 'App\GraphQL\Query\UsersQuery'
      //          ],
      //          'mutation' =&gt; [
      //
      //          ]
      //     ]
      // ]
      //
      'schemas' =&gt; [
          'default' =&gt; [
              'query' =&gt; [
                  'posts' =&gt; 'App\GraphQL\Query\PostsQuery'
              ],
              'mutation' =&gt; [
                  'newPost' =&gt; 'App\GraphQL\Mutation\NewPostMutation',
                  //'updatePostStatus' =&gt; App\GraphQL\Mutation\UpdatePostStatusMutation::class,
              ]
          ]
      ],
  
      // The types available in the application. You can then access it from the
      // facade like this: GraphQL::type('user')
      //
      // Example:
      //
      // 'types' =&gt; [
      //     'user' =&gt; 'App\GraphQL\Type\UserType'
      // ]
      //
      // or whitout specifying a key (it will use the -&gt;name property of your type)
      //
      'types' =&gt; [
          'App\GraphQL\Type\PostType',
      ],
      //
      //'types' =&gt; [
      //    'Post' =&gt; 'App\GraphQL\Type\PostType',
      //],
  
      // This callable will receive every Error object for each error GraphQL catches.
      // The method should return an array representing the error.
      //
      // Typically:
      // [
      //     'message' =&gt; '',
      //     'locations' =&gt; []
      // ]
      //
      'error_formatter' =&gt; ['\Folklore\GraphQL\GraphQL', 'formatError']
  
  ];
  </code></pre>
  
  <h2>-</h2>
  
  <p>-</p>
  
  <p><strong>UPDATE</strong>
  So I installed the Rebing library and uninstalled the Folklore one, and got GraphiQL to work. I ran a query in it and got </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>"message": "Class App\\GraphQL\\Type\\UserType does not exist",
    "exception": "ReflectionException",
    "file": "C:\\wamp64\\www\\laravel-project\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php",
    "line": 779,</code></pre>
  </div>
  </div>
  </p>
  
  <p>Something tells me I'm not supposed to be seeing paths like this. If this is wrong, how do I fix?</p>