Spring Boot GraphQL Tutorial #7 - Resolvers

Philip Starritt
Philip Starritt
18.3 هزار بار بازدید - 4 سال پیش - In GraphQL SpringBoot there are
In GraphQL SpringBoot there are two resolver marker interfaces, GraphQLQueryResolver and GraphQLResolver.

The GraphQLQueryResolver should contain methods that match the original graphql schema queries. If there is a mismatch and a method cannot be matched, the server will fail at runtime startup.

GraphQLResolver can be used to resolve nested fields within the GraphQLQueryResolver's response types.

I recommend that you consider making the field type returned from each GraphQLResolver nullable. If a resolver would throw an exception/fail, then the field would be set to null. A side effect of null on non-nullable field would be that the complete query will fail and return data: null as it failed schema response validation. If it was nullable, the query would as least return the other available fields.

In Video 11 I demo spring boot graphql asynchronous resolvers with completablefutures.

See you in the next video. Spring Boot GraphQL Exception Handling.

Cheers!
Philip

GraphQL Spring Boot: https://github.com/graphql-java-kicks...
4 سال پیش در تاریخ 1399/06/26 منتشر شده است.
18,386 بـار بازدید شده
... بیشتر