Skip to content

Navigation Menu

Sign in
Sign up

At least one schema should be declared #1192

Unanswered
martijn-moveyou asked this question in Q&A
Discussion options

I followed the installation steps in the readme file. Everything installs great.

In the config/types/ directory I start a greeting type with the filename Greeting.types.yaml with the following content:

Greeting:
 type: Object
 config:
 resolveField: '@=resolver("App\\GraphQL\\Resolver\\GreetingResolver", [info, value])'
 fields:
 text:
 type: String!
 args:
 name:
 type: String

I create a file with the name GreetingResolver in the App\GraphQL\Resolver\ package that des the resolve. It looks like this:

Class GreetingResolver implements QueryInterface
{
 public function __invoke(ResolveInfo $info, $value)
 {
 $method = $info->fieldName;
 if(!isset($info->variableValues['name'])) {
 return $this->$method($value);
 } else {
 return $this->$method($value, $info->variableValues['name']);
 }
 }
 
 public function resolve() :TypesGreetingEntity
 {
 return new GreetingEntity('Hi, ');
 }
 public function text(GreetingEntity $greetingEntity, string $name = '') :string
 {
 return $greetingEntity->greeting . ' ' . $name . '!';
 }
 
}

In the graphql/types/Query.types.yaml file I add the Queries:

Query:
 type: object
 config:
 fields:
 greeting:
 type: Greeting
 resolve: '@=resolver("App\\GraphQL\\Resolver\\GreetingResolver::resolve")'
 args:
 name:
 type: String

I then use postman to do a post call to http://localhost:8000/graphql/ and I then get the following error in my logs:

Uncaught PHP Exception RuntimeException: "At least one schema should be declare." at /var/www/vendor/overblog/graphql-bundle/src/Request/Executor.php line 82 {"exception":"[object] (RuntimeException(code: 0): At least one schema should be declare. at /var/www/vendor/overblog/graphql-bundle/src/Request/Executor.php:82)"} []

How do I define a schema? Is it needed?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /