Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravel With GraphQL

Laravel With GraphQL

A topic on embeding graphQL with laravel framework for a fast and sophisticated way of api build and consumption.

Sujith Kumar

February 01, 2020
Tweet

Other Decks in Technology

Transcript

  1. 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
  2. What is GraphQL- ❏ Query Language ( GraphQL Schema Language

    ) ❏ Type System type User { id name email } type Query { user { id name email } } type Mutation { createUser(name:“x”, email:“y”) { id name email } }
  3. { allPosts { id title created_at user { id name

    } } } { "data": { "allPosts": [ { "id": "1", "title": "Assumenda …//.", "created_at": "2020-01//.", "user": { "id": "1", "name": "Veda Ruecker" } }, {//.}, ] } } Declarative Data Fetching
  4. Steps - Laravel & GraphQL • Installation & setup •

    Defining Type for model • Query type • Relationships • Pagination • Mutations • Authentication
  5. 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