From 12915bf8194ef9cdd5678aaffb9701930b445ec2 Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Thu, 2 May 2019 16:05:07 -0400 Subject: [PATCH 1/2] push raw default test --- src/test/testMergeSchemas.ts | 10 ++++++++++ src/test/testingSchemas.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/test/testMergeSchemas.ts b/src/test/testMergeSchemas.ts index 184f57cfca8..b14495512ff 100644 --- a/src/test/testMergeSchemas.ts +++ b/src/test/testMergeSchemas.ts @@ -12,6 +12,7 @@ import { defaultFieldResolver, GraphQLField, findDeprecatedUsages, + printSchema, } from 'graphql'; import mergeSchemas from '../stitching/mergeSchemas'; import { @@ -24,6 +25,7 @@ import { remoteProductSchema, subscriptionPubSub, subscriptionPubSubTrigger, + rawDefaultSchema, } from './testingSchemas'; import { SchemaDirectiveVisitor } from '../schemaVisitor'; import { forAwaitEach } from 'iterall'; @@ -263,6 +265,7 @@ testCombinations.forEach(async combination => { let mergedSchema: GraphQLSchema, propertySchema: GraphQLSchema, productSchema: GraphQLSchema, + rawMergedSchema: GraphQLSchema, bookingSchema: GraphQLSchema; before(async () => { @@ -270,6 +273,9 @@ testCombinations.forEach(async combination => { bookingSchema = await combination.booking; productSchema = await combination.product; + rawMergedSchema = mergeSchemas({ schemas: [rawDefaultSchema] }); + + mergedSchema = mergeSchemas({ schemas: [ propertySchema, @@ -1162,6 +1168,10 @@ bookingById(id: "b1") { }); }); + it('input object with default and raw schema', async () => { + expect(printSchema(rawMergedSchema)).to.equal(rawDefaultSchema); + }); + it('deep links', async () => { const mergedResult = await graphql( mergedSchema, diff --git a/src/test/testingSchemas.ts b/src/test/testingSchemas.ts index 79c455d43be..feed871a12e 100644 --- a/src/test/testingSchemas.ts +++ b/src/test/testingSchemas.ts @@ -304,6 +304,16 @@ const propertyRootTypeDefs = ` } `; +const simpleRawDefaultTest = ` +input InputWithDefault { + test: String = "Foo" +} +type Query { + defaultInputTest(input: InputWithDefault!): String +} +`; +export const rawDefaultSchema: string = simpleRawDefaultTest; + const propertyAddressTypeDefs = ` scalar DateTime scalar JSON From 51466516e03ee42581c8d32b6187f6825260d470 Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Thu, 2 May 2019 16:20:42 -0400 Subject: [PATCH 2/2] add logs to show issue --- src/stitching/typeFromAST.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stitching/typeFromAST.ts b/src/stitching/typeFromAST.ts index 69367beefb3..0c6743d171a 100644 --- a/src/stitching/typeFromAST.ts +++ b/src/stitching/typeFromAST.ts @@ -181,6 +181,9 @@ function makeValues(nodes: ReadonlyArray) { const result = {}; nodes.forEach(node => { const type = resolveType(node.type, 'input') as GraphQLInputType; + console.info(`the Type is ${type}`); + console.info(`incorrect/undefined default ${valueFromAST(node.defaultValue, type)}`); + console.info(`correct default ${valueFromAST(node.defaultValue, GraphQLString)}`); result[node.name.value] = { type, defaultValue: valueFromAST(node.defaultValue, type),