Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
npm-debug.log
/.nyc_output/
/coverage/
.idea/
2 changes: 1 addition & 1 deletion lib/graphQl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jsonApiGraphQL.generateWriteSchema = (allReadTypes, allResourceConfig, allWriteT
result[`delete${uName}`] = {
description: `Delete a ${resourceConfig.resource} resource`,
args: {
id: { type: new graphQl.GraphQLNonNull(graphQl.GraphQLString) }
id: { type: new graphQl.GraphQLNonNull(graphQl.GraphQLInt) }
},
type: allReadTypes[resource],
resolve: resolvers.delete.bind(resolvers, resourceConfig)
Expand Down
2 changes: 1 addition & 1 deletion lib/graphQl/joiConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const oneRelationship = new graphQl.GraphQLInputObjectType({
name: 'oneRelationship',
fields: {
id: {
type: new graphQl.GraphQLNonNull(graphQl.GraphQLString),
type: new graphQl.GraphQLNonNull(graphQl.GraphQLInt),
description: 'The UUID of another resource'
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/graphQl/readTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ readTypes.createReadType = (resourceConfig, otherTypes, allUnionTypes) => {
fields () {
const fields = {
id: {
type: new graphQl.GraphQLNonNull(graphQl.GraphQLString),
type: new graphQl.GraphQLNonNull(graphQl.GraphQLInt),
description: 'The UUID of the resource'
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/graphQl/writeArgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const joiConverter = require('./joiConverter.js')

writeArgs.generate = (resource, allWriteTypes) => {
const args = {
id: { type: graphQl.GraphQLString }
id: { type: graphQl.GraphQLInt }
}
const resourceConfig = jsonApi._resources[resource]
Object.keys(resourceConfig.attributes).forEach(attribute => {
Expand Down
2 changes: 1 addition & 1 deletion lib/jsonApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jsonApi.define = resourceConfig => {
}, resourceConfig.searchParams, pagination.joiPageDefinition)

resourceConfig.attributes = _.assign({
id: ourJoi.Joi.string().required()
id: ourJoi.Joi.number().integer().required()
.description('Unique resource identifier')
.example('1234'),
type: ourJoi.Joi.string().required().valid(resourceConfig.resource)
Expand Down
2 changes: 1 addition & 1 deletion lib/ourJoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Joi = require('joi')

ourJoi._joiBase = resourceName => {
const relationType = Joi.object().keys({
id: Joi.string().required(),
id: Joi.number().integer().required(),
type: Joi.any().required().valid(resourceName),
meta: Joi.object().optional()
})
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ createRoute.register = () => {
const theirs = request.params.data
theirResource = _.assign(
{
id: uuid.v4(),
id: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 0 here as a "DEFAULT" value.
Putting the onus on the store handler (relattionaldb) to treat 0 = DEFAULT and if the value is 0, then generate new id, if not 0, then use it like a client provided id.

see championswimmer/jsonapi-store-sequelize@ee0b9f0#diff-8004fa36f21fa5eeb3c49b89106f6942R9 for example implementation

type: request.params.type
},
theirs.id && { id: theirs.id },
Expand Down
4 changes: 2 additions & 2 deletions lib/swagger/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ swaggerPaths._getPathOperationObject = options => {
in: 'path',
description: 'id of specific instance to lookup',
required: true,
type: 'string'
type: 'number'
})
}

Expand Down Expand Up @@ -320,7 +320,7 @@ swaggerPaths._getRelationModel = () => ({
type: 'string'
},
id: {
type: 'string'
type: 'number'
},
meta: {
type: 'object'
Expand Down
2 changes: 1 addition & 1 deletion lib/swagger/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ swaggerPaths._getResourceDefinition = resourceConfig => {
type: 'string'
},
id: {
type: 'string'
type: 'number'
},
meta: {
type: 'object'
Expand Down