What is a custom context and why do I need one in graphql?
In graphql spring boot, you have the ability to create a custom object once at the very start of the query/mutation, and this object will be available to all mutations and queries via the DataFetchingEnvironment. The custom object can be any type, and is never used by the internal graphql java framework.
As the context is created once and available in all revolvers; a common use-case to store user authorization data such as user id, permissions and roles. This data can then be used to perform authorization on your mutation and resolvers. An alternative to this is spring security and pass the security context to other threads via DelegatingSecurityContextExecutorService. But the context file can contain anything you wish.
See you in the next video where we use the facebook dataLoaders to solve the N+1 problem!
Cheers!
Philip
Spring Boot GraphQL DataFetchingEnvironment breakdown: • Spring Boot GraphQL Tutorial #14 - Da...
Spring Boot GraphQL Java: https://github.com/graphql-java-kicks...
Spring Security DelegatingSecurityContextExecutorService to pass auth data between threads: https://docs.spring.io/spring-securit...
Thumbnail character vector referenced from freepik: www.freepik.com
On this page of the site you can watch the video online Spring Boot GraphQL Tutorial #22 - Custom Context with a duration of hours minute second in good quality, which was uploaded by the user Philip Starritt 26 September 2020, share the link with friends and acquaintances, this video has already been watched 6,755 times on youtube and it was liked by 63 viewers. Enjoy your viewing!