Skip to content

Commit 7fb88f3

Browse files
committed
fix(core): Fixed the core, added tests
1 parent 705a89a commit 7fb88f3

File tree

4 files changed

+405
-22
lines changed

4 files changed

+405
-22
lines changed

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "AVA",
11+
"program": "${workspaceRoot}/node_modules/ava/profile.js",
12+
"args": ["--serial", "${file}"],
13+
"skipFiles": ["<node_internals>/**/*.js"]
14+
}
15+
]
16+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"prepublish": "npm run test",
1717
"build": "rm -rf dist && tsc -d",
1818
"lint": "tslint --project tsconfig.json {src}/**/*.ts && prettier-check --ignore-path .gitignore {src,.}/{*.ts,*.js}",
19-
"test": "npm run lint && npm run build",
19+
"test": "npm run lint && npm run build && npm run test-ava",
20+
"test-ava": "ava --verbose",
2021
"semantic-release": "semantic-release"
2122
},
2223
"dependencies": {

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
GraphQLArgument,
44
GraphQLField,
55
getNamedType,
6+
GraphQLType,
67
} from 'graphql'
78
import { GraphQLUpload } from 'apollo-upload-server'
89
import { IMiddlewareFunction } from 'graphql-middleware'
@@ -70,7 +71,7 @@ function filterMap<T, U>(f: (x: T) => Maybe<U>, xs: T[]): U[] {
7071
*
7172
*/
7273
function getArgumentValue(args: { [key: string]: any }, arg: GraphQLArgument) {
73-
return args.get(arg.name)
74+
return args[arg.name]
7475
}
7576

7677
/**
@@ -106,10 +107,10 @@ export function filterMapFieldArguments<T>(
106107
*
107108
*/
108109
export function isGraphQLArgumentType(
109-
type,
110+
type: GraphQLType,
110111
argument: GraphQLArgument,
111112
): boolean {
112-
return getNamedType(argument.type) instanceof type
113+
return getNamedType(argument.type).name === getNamedType(type).name
113114
}
114115

115116
// Upload --------------------------------------------------------------------
@@ -145,7 +146,7 @@ interface IConfig<T> {
145146
* Funciton used to identify GraphQLUpload arguments.
146147
*
147148
*/
148-
function uploadTypeIdentifier(
149+
export function uploadTypeIdentifier(
149150
def: GraphQLArgument,
150151
value: any,
151152
): IUploadArgument {
@@ -182,7 +183,7 @@ function extractUploadArguments(
182183
* be later used as arguments definition.
183184
*
184185
*/
185-
function normaliseArguments<T>(
186+
export function normaliseArguments<T>(
186187
args: IProcessedUploadArgument<T>[],
187188
): { [key: string]: T } {
188189
return args.reduce((acc, val) => {

0 commit comments

Comments
 (0)