apollo-graphql
Advanced tools
Comparing version
@@ -163,3 +163,6 @@ "use strict"; | ||
values.forEach(value => { | ||
const newValue = fieldConfigs[value.name] || value.name; | ||
let newValue = fieldConfigs[value.name]; | ||
if (newValue === undefined) { | ||
newValue = value.name; | ||
} | ||
newValues[value.name] = { | ||
@@ -166,0 +169,0 @@ value: newValue, |
{ | ||
"name": "apollo-graphql", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Apollo GraphQL utility library", | ||
@@ -20,3 +20,29 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "4eea9a99d77e426e5fd03594fadbb4ed6d716da4" | ||
"jest": { | ||
"preset": "ts-jest", | ||
"transformIgnorePatterns": [ | ||
"/node_modules/" | ||
], | ||
"testEnvironment": "node", | ||
"testMatch": [ | ||
"**/__tests__/*.(js|ts)" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/node_modules/", | ||
"<rootDir>/lib/", | ||
"<rootDir>/test/fixtures/", | ||
"<rootDir>/test/test-utils" | ||
], | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js" | ||
], | ||
"globals": { | ||
"ts-jest": { | ||
"tsConfig": "<rootDir>/tsconfig.test.json", | ||
"diagnostics": false | ||
} | ||
} | ||
}, | ||
"gitHead": "6d168194f3ee0563b4105b41a39f39d8c1fd80e8" | ||
} |
@@ -506,3 +506,50 @@ import gql from "graphql-tag"; | ||
}); | ||
it(`should add resolvers to enum types with 0 value`, () => { | ||
const typeDefs = gql` | ||
enum CustomerType { | ||
EXISTING | ||
NEW | ||
} | ||
type Query { | ||
existingCustomer: CustomerType | ||
newCustomer: CustomerType | ||
} | ||
`; | ||
const resolvers = { | ||
CustomerType: { | ||
EXISTING: 0, | ||
NEW: 1 | ||
}, | ||
Query: { | ||
existingCustomer: () => 0, | ||
newCustomer: () => 1 | ||
} | ||
}; | ||
const schema = buildSchemaFromSDL([{ typeDefs, resolvers }]); | ||
const customerTypeEnum = schema.getType( | ||
"CustomerType" | ||
) as GraphQLEnumType; | ||
let result = execute( | ||
schema, | ||
gql` | ||
query { | ||
existingCustomer | ||
newCustomer | ||
} | ||
` | ||
); | ||
expect((result as ExecutionResult).data!.existingCustomer).toBe( | ||
"EXISTING" | ||
); | ||
expect(customerTypeEnum.getValue("EXISTING")!.value).toBe(0); | ||
expect((result as ExecutionResult).data!.newCustomer).toBe("NEW"); | ||
expect(customerTypeEnum.getValue("NEW")!.value).toBe(1); | ||
}); | ||
}); | ||
}); |
import { ASTNode, print } from "graphql"; | ||
import { Plugin, Config } from "pretty-format"; | ||
import { Plugin, Config, Refs, Printer } from "pretty-format"; | ||
@@ -9,3 +9,10 @@ export = (({ | ||
serialize(value: ASTNode, _config: Config, indentation: string): string { | ||
serialize( | ||
value: ASTNode, | ||
config: Config, | ||
indentation: string, | ||
depth: number, | ||
refs: Refs, | ||
printer: Printer | ||
): string { | ||
return ( | ||
@@ -12,0 +19,0 @@ indentation + |
import { isNamedType, GraphQLNamedType, printType } from "graphql"; | ||
import { Plugin } from "pretty-format"; | ||
import { Plugin, Config, Refs, Printer } from "pretty-format"; | ||
@@ -9,5 +9,12 @@ export = (({ | ||
serialize(value: GraphQLNamedType): string { | ||
serialize( | ||
value: GraphQLNamedType, | ||
config: Config, | ||
indentation: string, | ||
depth: number, | ||
refs: Refs, | ||
printer: Printer | ||
): string { | ||
return printType(value); | ||
} | ||
} as Plugin) as unknown) as jest.SnapshotSerializerPlugin; |
import { print, SelectionNode, isSelectionNode } from "graphql"; | ||
import { Plugin } from "pretty-format"; | ||
import { Plugin, Config, Refs, Printer } from "pretty-format"; | ||
@@ -11,5 +11,12 @@ export = (({ | ||
serialize(value: SelectionNode[]): string { | ||
serialize( | ||
value: SelectionNode[], | ||
config: Config, | ||
indentation: string, | ||
depth: number, | ||
refs: Refs, | ||
printer: Printer | ||
): string { | ||
return String(print(value)).replace(",", "\n"); | ||
} | ||
} as Plugin) as unknown) as jest.SnapshotSerializerPlugin; |
@@ -240,3 +240,6 @@ import { | ||
values.forEach(value => { | ||
const newValue = (fieldConfigs as any)[value.name] || value.name; | ||
let newValue = (fieldConfigs as any)[value.name]; | ||
if (newValue === undefined) { | ||
newValue = value.name; | ||
} | ||
newValues[value.name] = { | ||
@@ -243,0 +246,0 @@ value: newValue, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93873
2.45%2108
3.33%