blogs.karthikeyanvk.in
IS REST Dead? Learn through GraphQL.Net
Karthikeyan VK
https://blogs.karthikeyanvk.in
@karthik3030
blogs.karthikeyanvk.in
Enter Text IS REST Dying ?
blogs.karthikeyanvk.in
Enter Text
Why GRAPHQL?
Simplified Workflow(Single
endpoint)
Remove over and under fetching
Avoid multiple round trips
blogs.karthikeyanvk.in
Enter Text
Why GRAPHQL?
Type Safety
Increased velocity of
development
Improved developer experience
blogs.karthikeyanvk.in
Enter Text
Simplified Workflow
blogs.karthikeyanvk.in
Enter Text
Remove Over and Under fetching
blogs.karthikeyanvk.in
Enter Text
Avoid Multiple Round trips
blogs.karthikeyanvk.in
Enter Text
Type Safety
blogs.karthikeyanvk.in
Enter Text
Increased velocity of
development
blogs.karthikeyanvk.in
Enter Text
Improved developer experience
blogs.karthikeyanvk.in
Enter Text
Transition of Data Transfer
REST REST-RPC GRAPHQL
blogs.karthikeyanvk.in
Enter Text
DEMO
blogs.karthikeyanvk.in
Enter Text
What is GraphQL?
GraphQL is a query language for your API, and a
server-side runtime for executing queries by using a
type system you define for your data.
blogs.karthikeyanvk.in
Enter Text
What is Graph in GraphQL?
blogs.karthikeyanvk.in
Enter Text
What is GraphiQL?
GraphiQL is an interactive in-browser GraphQL IDE.
blogs.karthikeyanvk.in
Enter Text
DEMO
blogs.karthikeyanvk.in
Enter Text
Schema Types
blogs.karthikeyanvk.in
Enter Text
Queries
public class StarWarsQuery : ObjectGraphType
{
public StarWarsQuery()
{
Field<DroidType>( "hero", resolve: context => new Droid { Id = "1", Name = "R2-D2" } );
}
}
blogs.karthikeyanvk.in
Enter Text
Mutation
mutation newNHL($player: PlayerInput!)
{
createPlayer(player: $player)
{
name
id
}
}
blogs.karthikeyanvk.in
Enter Text
Subscriptions
Subscriptions creates a two way communication between the client and server like
SignalR
blogs.karthikeyanvk.in
Enter Text
Malicious Queries
blogs.karthikeyanvk.in
Enter Text
Validation and Authorization
blogs.karthikeyanvk.in
Enter Text
Validation and Authorization
blogs.karthikeyanvk.in
Enter Text
DEMO
blogs.karthikeyanvk.in
Enter Text
Best Practices
Naming Matters
Think in Graph and not in endpoints
Improved developer experience
Describe the data, not the view
Remember, GraphQL is thin Interface
blogs.karthikeyanvk.in
Enter Text
Best Practices
Naming Matters
Think in Graph and not in endpoints
Improved developer experience
Describe the data, not the view
Remember, GraphQL is thin Interface
blogs.karthikeyanvk.in
Enter Text
Migration Strategies
Solve a real problem
Think like a client
Have a first client
Incremental Adoption
Finally YAGNI
blogs.karthikeyanvk.in
Enter Text
References
@karthik3030
• https://graphql-dotnet.github.io/docs/getting-started/introduction
• https://fullstackmark.com/post/17/building-a-graphql-api-with-aspnet-core-2-and-entity-
framework-core
blogs.karthikeyanvk.in
Enter Text
@karthik3030
Thank you
/Q&A

Learning graphql .Net

Editor's Notes

  • #4 Talk about nested query
  • #19 The Schema first approach relies upon the GraphQL schema language, coding conventions, and tries to provide a minimal amount of syntax. It is the easiest to get started though it does not currently support some advanced scenarios. The GraphType first approach can be more verbose, but gives you access to all of the provided properties of your GraphType's and Schema. You are required to use inheritance to leverage that functionality.
  • #22 MaxComplexity & FieldImpact For example if I have 3 tables with 100, 120 and 98 rows and I know I will be querying the first table twice as much then a good estimation for avgImpact would be 105.
  • #24 https://graphql-dotnet.github.io/docs/getting-started/authorization
  • #25  Define ObjectGraphType Define InputObjectGraphType Define query or mutation Type Define schema and register them with resolve
  • #27 MaxComplexity & FieldImpact For example if I have 3 tables with 100, 120 and 98 rows and I know I will be querying the first table twice as much then a good estimation for avgImpact would be 105.
  • #28 Finding real problem get you grounded about features to prioritize Think like client and see who will be using it.