A topic on embeding graphQL with laravel framework for a fast and sophisticated way of api build and consumption.
Hi, I’m Sujith KumarI work at AlphaWebLab
View Slide
GraphQLGraphQL is a query language for your API, and aserver-side runtime for executing queries by using atype system you define for your data
What is GraphQL-❏ Query Language ( GraphQL Schema Language )❏ Type Systemtype User {idnameemail}type Query {user {idnameemail}}type Mutation {createUser(name:“x”, email:“y”) {idnameemail}}
❏ Declarative Data Fetching❏ Self Documenting
GET /posts
{allPosts {idtitlecreated_atuser {idname}}}{"data": {"allPosts": [{"id": "1","title": "Assumenda …//.","created_at": "2020-01//.","user": {"id": "1","name": "Veda Ruecker"}},{//.},]}}Declarative Data Fetching
Hands-On
Steps - Laravel & GraphQL● Installation & setup● Defining Type for model● Query type● Relationships● Pagination● Mutations● Authentication
Steps - Laravel & GraphQL● laravel new projectName - Create new laravel project● composer require nuwave/lighthouse - Install Lighthouse Package● Publish default schema:- Run php artisan vendor:publish--provider="Nuwave\Lighthouse\LighthouseServiceProvider" --tag=schema● Publish default config:● - Run php artisan vendor:publish--provider="Nuwave\Lighthouse\LighthouseServiceProvider" --tag=config● Install graphql-playground:- Run composer require mll-lab/laravel-graphql-playground
Parameters of a resolver fn
Github[https://github.com/SujithJr/laravel-graphql]SpeakerDeck[https://speakerdeck.com/sujithjr/laravel-with-graphql]
Thank You@codenameJr iamsanju.jr