LoginSignup
1
0

More than 5 years have passed since last update.

Node.js&GraphQL part2 ~ Mutation / Subscription / お絵描き ~

Posted at

MutationsとSubscriptionについてまとめようと思ったけどQiitaのプラットフォームでは自分には不可能だったので、自分のためだけにお絵描きと簡単なメモを残します。

・Query: Read
・Mutation: Create / Update / Delete
・Subscription: WebSocketでRealtimeに読み取り

https://github.com/hugo-ishikawa/GraphQL-Mutation-Subscription

お絵描き

index.js
import { GraphQLServer, PubSub } from 'graphql-yoga'
import db from './db'
import Query from './resolvers/Query'
import Mutation from './resolvers/Mutation'
import Subscription from './resolvers/Subscription'
import User from './resolvers/User'
import Post from './resolvers/Post'
import Comment from './resolvers/Comment'

const pubsub = new PubSub()

const server = new GraphQLServer({
    typeDefs: './src/schema.graphql',
    resolvers: {
        Query,
        Mutation,
        Subscription,
        User,
        Post,
        Comment
    },
    context: {
        db,
        pubsub
    }
})

server.start(() => {
    console.log('server is up');
})

イラスト.jpg

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0