Skip to content

Cleanedup default example #1120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/stitching/typeFromAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ function makeValues(nodes: ReadonlyArray<InputValueDefinitionNode>) {
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),
Expand Down
10 changes: 10 additions & 0 deletions src/test/testMergeSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
defaultFieldResolver,
GraphQLField,
findDeprecatedUsages,
printSchema,
} from 'graphql';
import mergeSchemas from '../stitching/mergeSchemas';
import {
Expand All @@ -24,6 +25,7 @@ import {
remoteProductSchema,
subscriptionPubSub,
subscriptionPubSubTrigger,
rawDefaultSchema,
} from './testingSchemas';
import { SchemaDirectiveVisitor } from '../schemaVisitor';
import { forAwaitEach } from 'iterall';
Expand Down Expand Up @@ -263,13 +265,17 @@ testCombinations.forEach(async combination => {
let mergedSchema: GraphQLSchema,
propertySchema: GraphQLSchema,
productSchema: GraphQLSchema,
rawMergedSchema: GraphQLSchema,
bookingSchema: GraphQLSchema;

before(async () => {
propertySchema = await combination.property;
bookingSchema = await combination.booking;
productSchema = await combination.product;

rawMergedSchema = mergeSchemas({ schemas: [rawDefaultSchema] });


mergedSchema = mergeSchemas({
schemas: [
propertySchema,
Expand Down Expand Up @@ -1172,6 +1178,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,
Expand Down
10 changes: 10 additions & 0 deletions src/test/testingSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down