mongodb-stitch
Advanced tools
Comparing version 3.8.1 to 3.9.0
@@ -769,2 +769,25 @@ 'use strict'; | ||
return api._get(graphqlUrl + '/validate'); | ||
}, | ||
customResolvers: function customResolvers() { | ||
return { | ||
list: function list() { | ||
return api._get(graphqlUrl + '/custom_resolvers'); | ||
}, | ||
create: function create(data) { | ||
return api._post(graphqlUrl + '/custom_resolvers', data); | ||
}, | ||
customResolver: function customResolver(id) { | ||
return { | ||
get: function get() { | ||
return api._get(graphqlUrl + '/custom_resolvers/' + id); | ||
}, | ||
update: function update(data) { | ||
return api._put(graphqlUrl + '/custom_resolvers/' + id, { body: JSON.stringify(data) }); | ||
}, | ||
remove: function remove() { | ||
return api._delete(graphqlUrl + '/custom_resolvers/' + id); | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
@@ -771,0 +794,0 @@ }; |
@@ -17,4 +17,4 @@ 'use strict'; | ||
var version = 'unknown'; | ||
if (typeof "3.8.1" !== 'undefined') { | ||
version = "3.8.1"; | ||
if (typeof "3.9.0" !== 'undefined') { | ||
version = "3.9.0"; | ||
} | ||
@@ -21,0 +21,0 @@ var SDK_VERSION = exports.SDK_VERSION = version; |
{ | ||
"name": "mongodb-stitch", | ||
"version": "3.8.1", | ||
"version": "3.9.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "", |
@@ -465,3 +465,12 @@ /* global window, fetch */ | ||
post: (data) => api._post(`${graphqlUrl}`, data), | ||
validate: () => api._get(`${graphqlUrl}/validate`) | ||
validate: () => api._get(`${graphqlUrl}/validate`), | ||
customResolvers: () => ({ | ||
list: () => api._get(`${graphqlUrl}/custom_resolvers`), | ||
create: data => api._post(`${graphqlUrl}/custom_resolvers`, data), | ||
customResolver: (id) => ({ | ||
get: () => api._get(`${graphqlUrl}/custom_resolvers/${id}`), | ||
update: data => api._put(`${graphqlUrl}/custom_resolvers/${id}`, { body: JSON.stringify(data) }), | ||
remove: () => api._delete(`${graphqlUrl}/custom_resolvers/${id}`) | ||
}) | ||
}) | ||
}; | ||
@@ -468,0 +477,0 @@ }, |
@@ -60,2 +60,45 @@ const StitchMongoFixture = require('../fixtures/stitch_mongo_fixture'); | ||
}); | ||
describe('custom_resolvers', () => { | ||
let myResolver; | ||
beforeEach(async(done) => { | ||
myResolver = await graphql.customResolvers().create({ | ||
field_name: 'myResolver', | ||
on_type: 'Query', | ||
function_id: '5a1154523a6bcc1d245e143d' | ||
}); | ||
done(); | ||
}); | ||
it('.list', async() => { | ||
const response = await graphql.customResolvers().list(); | ||
expect(response).toEqual([myResolver]); | ||
}); | ||
it('.create', async() => { | ||
expect(myResolver).toMatchObject({ | ||
field_name: 'myResolver', | ||
function_id: '5a1154523a6bcc1d245e143d', | ||
on_type: 'Query' | ||
}); | ||
}); | ||
it('.get', async() => { | ||
const response = await graphql.customResolvers().customResolver(myResolver._id).get(); | ||
expect(response).toEqual(myResolver); | ||
}); | ||
it('.update', async() => { | ||
const update = Object.assign({}, myResolver, { on_type: 'Mutation'}); | ||
const response = await graphql.customResolvers().customResolver(myResolver._id).update(update); | ||
expect(response.status).toEqual(204); | ||
}); | ||
it('.remove', async() => { | ||
await graphql.customResolvers().customResolver(myResolver._id).remove(); | ||
const response = await graphql.customResolvers().list(); | ||
expect(response).toEqual([]); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
5418182
133
25292