Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@hugo_23

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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?