Spring Boot GraphQL Tutorial #22 - Custom Context

Veröffentlicht am: 26 September 2020
auf dem Kanal: Philip Starritt
6,755
63

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


Auf dieser Seite können Sie das Online-Video Spring Boot GraphQL Tutorial #22 - Custom Context mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Philip Starritt 26 September 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 6,755 Mal angesehen und es wurde von 63 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!