Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Webシステム開発事例 と GraphQL Server with Laravel
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
@
November 30, 2019
55
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Webシステム開発事例 と GraphQL Server with Laravel
@
November 30, 2019
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
170
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
300
WCS-LA-2024
lcolladotor
0
650
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.7k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
The Pragmatic Product Professional
lauravandoore
37
7.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Accessibility Awareness
sabderemane
1
140
Why Our Code Smells
bkeepers
PRO
340
58k
Transcript
Webシステム開発事例 と GraphQL Server with Laravel 2019-11-30 atomita
琉球インタラクティブとは?
「日本を代表するインターネット企業になる」 を掲げ 求人マッチングサービス運営や、主に沖縄企業 を対象としたプロモーションプランニング、受 託開発などを手がけ 1つ1つの事業を成長させつつ、新しい事業にも 挑戦
Webシステム開発事例
御菓子御殿 お取り寄せショップ https://www.okashigoten.com/ 那覇空港旅客ターミナル オフィシャルサイト https://www.naha-airport.co.jp/ JOB ANTENNA https://www.jobantenna.jp/ ほかにもご興味ある方はこちら
PHP >> Node.js >> Go > Python
LaravelでGraphQL
https://github.com/search? q=laravel+graphql&type=Repositories folkloreinc/laravel-graphql nuwave/lighthouse rebing/graphql-laravel
Lighthouse-phpの良いところ
GraphQL Schema Definition Languageで schemaを定義 簡単にEloquent Model(ORM)と連携 Validationや、アクセス制限はLaravelの機能を 利用
Demo
ご静聴、ありがとうございまし た
おまけ
wget https://github.com/laradock/laradock/archive/v8.0.zip unzip v8.0.zip mv laradock-8.0 laradock cp laradock/env-example laradock/.env
sed -i -e 's/^\(APP_CODE_PATH_HOST=\).*$/\1..\/laravel/' laradock/.env sed -i -e 's/^\(DATA_PATH_HOST=\).*$/\1..\/data/' laradock/.env sed -i -e 's/^\(COMPOSE_PROJECT_NAME=\).*$/\1laradock_techplay20191130/' laradock/.env sed -i -e 's/^\(MYSQL_VERSION=\).*$/\15.7/' laradock/.env wget https://github.com/laravel/laravel/archive/v6.5.2.zip unzip v6.5.2.zip mv laravel-6.5.2 laravel cp laravel/.env.example laravel/.env sed -i -e 's/^\(DB_HOST=\).*$/\1mysql/' laravel/.env sed -i -e 's/^\(DB_DATABASE=\).*$/\1default/' laravel/.env sed -i -e 's/^\(DB_USERNAME=\).*$/\1default/' laravel/.env sed -i -e 's/^\(DB_PASSWORD=\).*$/\1secret/' laravel/.env (cd laradock; docker-compose up nginx mysql workspace) & (cd laradock; docker-compose exec --user=laradock workspace bash)
composer install php artisan key:generate composer require laravel/ui --dev php
artisan ui -n vue --auth php artisan migrate npm install && npm run dev
composer require nuwave/lighthouse php artisan vendor:publish --provider="Nuwave\Lighthouse\LighthouseServiceProvider" --tag=schema php artisan
vendor:publish --provider="Nuwave\Lighthouse\LighthouseServiceProvider" --tag=config sed -i -e 's/\('\''middleware'\''.*\)/\1\n \\Illuminate\\Session\\Middleware\\StartSession::class,/' config/lighthouse.php sed -i -e 's/\('\''middleware'\''.*\)/\1\n \\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse::class,/' config/lighthouse.php sed -i -e 's/\('\''middleware'\''.*\)/\1\n \\App\\Http\\Middleware\\EncryptCookies::class,/' config/lighthouse.php composer require mll-lab/laravel-graphql-playground
cat << 'EOF' > database/migrations/2019_11_30_000000_create_posts_table.php <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; class CreatePostsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->text('title'); $table->text('contents'); $table->unsignedBigInteger('user_id')->nullable(); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users')->onDelete('set null'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('posts'); } } EOF
cat << 'EOF' > app/Post.php <?php namespace App; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; class Post extends Model { protected $fillable = ['title', 'contents', 'user_id']; public function user(): BelongsTo { return $this->belongsTo(User::class); } } EOF
cat << 'EOF' >> graphql/schema.graphql type Mutation extend type Query
{ posts: [Post!]! @paginate(defaultCount: 10) post(id: ID @eq): Post @find } type Post { id: ID! title: String! contents: String! created_at: DateTime! updated_at: DateTime! user: User @belongsTo } extend type Mutation { createPost( title: String! contents: String! ): Post @create @inject(context: "user.id", name: "user_id") } EOF
php artisan migrate
open http://localhost/graphql-playground # setting # "request.credentials": "same-origin" # mutation {
createPost(title: "bar" contents: "baz") { id } } # query { posts { data { id title contents created_at updated_at user { id name } } } }