Skip to content

Commit

Permalink
Addign name to cable table
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagocmoreira committed May 16, 2019
1 parent 8e4bf29 commit 062e0c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions migrations/20190510012439_create_table_cable.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function up (knex) {
return knex.schema.createTable('cables', (table) => {
table.uuid('id').primary()
table.string('general_state')
table.string('name')
table.integer('size') // Milimeters
table.integer('diameter') // Milimeters
table.integer('lifespan') // Days
Expand Down
3 changes: 2 additions & 1 deletion src/mutations/cables.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { knexInstance } from '../db'
import uuid from 'uuid/v4'

export default {
createCable: async (root, { size, diameter, lifespan }, context, info) => {
createCable: async (root, { name, size, diameter, lifespan }, context, info) => {
try {
let cableId = await knexInstance('cables')
.returning('id')
.insert({
id: uuid(),
name: name,
size: size,
diameter: diameter,
lifespan: lifespan
Expand Down
3 changes: 2 additions & 1 deletion src/type-defs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type File {
type Cable {
id: ID
name: String
lifespan: Int
diameter: Int
size: Int
Expand Down Expand Up @@ -50,7 +51,7 @@ type Query {
# Mutations
type Mutation {
createCable (size: Int!, diameter: Int!, lifespan: Int!): ID
createCable (name: String, size: Int!, diameter: Int!, lifespan: Int!): ID
updateCable (id: ID!, lifespan: Int, generalState: String): Cable
deleteCable (id: ID!): Boolean
createReport: ID
Expand Down

0 comments on commit 062e0c7

Please sign in to comment.