Skip to content

Commit

Permalink
Upgrade to rxjs 6 and make uncompiled typescript friendly (#11)
Browse files Browse the repository at this point in the history
* upgrade to rxjs 6

* remove usage of spread for typescript sake

* fix
  • Loading branch information
MikaAK authored and ihorkatkov committed Oct 10, 2018
1 parent 9e58099 commit dc8d682
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"presets": ["env"],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
"transform-class-properties"
]
}
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*
!lib/*
.git
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.3.0",
"description": "A network interface for Apollo that enables file-uploading to Absinthe back ends.",
"main": "lib/index.js",
"module": "src/index.js",
"repository": "https://github.com/bytewitchcraft/apollo-absinthe-upload-link",
"author": "Ihor Katkov",
"license": "MIT",
Expand All @@ -17,15 +18,14 @@
"apollo-link-http": "^1.3.2",
"apollo-link-http-common": "^0.2.4",
"graphql": "0.11.3",
"rxjs": "5.4.3"
"rxjs": "~6.2.2"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-jest": "^22.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^4.14.0",
"eslint-plugin-prettier": "^2.4.0",
Expand All @@ -36,5 +36,8 @@
"prettier": "1.9.2",
"regenerator-runtime": "^0.11.1",
"rimraf": "^2.6.2"
},
"peerDependencies": {
"rxjs": ">=6.0.0"
}
}
4 changes: 3 additions & 1 deletion src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ describe('#createUploadMiddleware', () => {

const result = request(operations, forward)

expect(result.headers).toEqual({ ...contextHeaders, ...optionsHeaders })
expect(result.headers).toEqual(
Object.assign({}, contextHeaders, optionsHeaders),
)
})
it('uses custom fetch function', done => {
const variables = { params: 'stub' }
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const createUploadMiddleware = ({ uri, headers, fetch }) =>
return new Observable(observer => {
fetch(uri, {
method: 'POST',
headers: { ...contextHeaders, ...headers },
headers: Object.assign({}, contextHeaders, headers),
body: formData,
})
.then(response => {
Expand All @@ -50,7 +50,7 @@ export const createUploadMiddleware = ({ uri, headers, fetch }) =>
return request({
uri,
body: formData,
headers: { ...contextHeaders, ...headers },
headers: Object.assign({}, contextHeaders, headers),
})
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/request.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Observable } from 'rxjs/Observable'
import 'rxjs/add/observable/dom/ajax'
import 'rxjs/add/operator/map'
import { ajax } from 'rxjs/ajax'
import { map } from 'rxjs/operators'

/**
* Request function
*
* @param {Object} opts
*/
const request = opts =>
Observable.ajax({
ajax({
url: opts.uri,
body: opts.body,
method: 'POST',
headers: opts.headers,
}).map(({ response }) => response)
}).pipe(map(({ response }) => response))

export default request
3 changes: 2 additions & 1 deletion src/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ export class ReactNativeFile {
* name: 'photo-2.jpg'
* }])
*/
static list = files => files.map(file => new ReactNativeFile(file))
}

ReactNativeFile.list = files => files.map(file => new ReactNativeFile(file))
14 changes: 9 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3253,11 +3253,11 @@ rx-lite@*, rx-lite@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"

rxjs@5.4.3:
version "5.4.3"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.3.tgz#0758cddee6033d68e0fd53676f0f3596ce3d483f"
rxjs@~6.2.2:
version "6.2.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.2.tgz#eb75fa3c186ff5289907d06483a77884586e1cf9"
dependencies:
symbol-observable "^1.0.1"
tslib "^1.9.0"

safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
Expand Down Expand Up @@ -3481,7 +3481,7 @@ supports-color@^4.0.0:
dependencies:
has-flag "^2.0.0"

symbol-observable@^1.0.1, symbol-observable@^1.0.2:
symbol-observable@^1.0.2:
version "1.1.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.1.0.tgz#5c68fd8d54115d9dfb72a84720549222e8db9b32"

Expand Down Expand Up @@ -3577,6 +3577,10 @@ trim-right@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"

tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"

tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
Expand Down

0 comments on commit dc8d682

Please sign in to comment.