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

GraphQL 開発で必要になったこと / What we needed for GraphQ...

GraphQL 開発で必要になったこと / What we needed for GraphQL development

We decided to use GraphQL in the next project.
I summarized to slides about what we needed for GraphQL development.
Slides for M3 tech meetup! #4

Takayuki Matsubara

September 27, 2018
Tweet

More Decks by Takayuki Matsubara

Other Decks in Programming

Transcript

  1. QBDLBHFKTPO ࢀߟ ҎԼʹ͜ͷޙͷࢿྉͰ࢖͍ͬͯΔαϯϓϧίʔυΛࡌͤͯ͋Γ·͢ IUUQTHJUIVCDPNNEFWHSBQIRMTQSJOHCPPULPUMJOTBNQMFQVMM { "name": "mock", "version": "1.0.0", "description":

    "graphql mock server", "dependencies": { "apollo-server-express": "^1.4.0", "body-parser": "^1.18.3", "express": "^4.16.3", "graphql": "^0.13.2", "graphql-tools": "^4.0.0" }, "scripts": { "start": "node ./index.js" }, "devDependencies": {}, "author": "Takayuki Matsubara", "license": "MIT" }
  2. JOEFYKT શମ const express = require('express'); const bodyParser = require('body-parser');

    const { graphqlExpress, graphiqlExpress } = require('apollo-server- express'); const { addMockFunctionsToSchema, makeExecutableSchema } = require('graphql-tools'); const typeDefs = require('./type_defs'); const schema = makeExecutableSchema({ typeDefs }); const mocks = require('./mocks') addMockFunctionsToSchema({ schema, mocks }); const app = express(); app.use('/graphql', bodyParser.json(), graphqlExpress({ schema })); app.use("/graphiql", graphiqlExpress({ endpointURL: "/graphql" })); app.listen(3000, () => { console.log('/graphiql is running'); });
  3. JOEFYKT ൈਮ const typeDefs = require('./type_defs'); const schema = makeExecutableSchema({

    typeDefs }); const mocks = require('./mocks') addMockFunctionsToSchema({ schema, mocks }); εΩʔϚΛఆٛ͢Δ
  4. UZQF@EFGTKT ൈਮ module.exports = ` … # ஶऀ type Author

    { id: ID! # ஶऀ໊ name: String! # ஶऀͷຊ books: [Book]! } # ຊ type Book { id: ID! # ໊લ name: String! } … `;
  5. JOEFYKT ൈਮ const typeDefs = require('./type_defs'); const schema = makeExecutableSchema({

    typeDefs }); const mocks = require('./mocks') addMockFunctionsToSchema({ schema, mocks }); ϞοΫΛఆٛ͢Δ
  6. NPDLTKT module.exports = { Author: () => ({ name: 'Takayuki

    Matsubara', }), Book: () => ({ name: 'Elixir Book', }), }; ࢀߟ ެࣜʹ΋ͬͱΧελϜͰ͖Δྫ͕͋Δ IUUQTXXXBQPMMPHSBQIRMDPNEPDTHSBQIRMUPPMTNPDLJOHIUNM