Skip to content

Commit

Permalink
Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sashko Stubailo committed Aug 17, 2017
1 parent e5e368a commit e65aa8a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/stitching/addSimpleRoutingResolvers.ts
Expand Up @@ -60,7 +60,7 @@ export default function addSimpleRoutingResolvers(
type instanceof GraphQLInterfaceType ||
type instanceof GraphQLUnionType
) {
type.resolveType = parent => resolveFromParentTypename(parent, schema);
resolvers[type.name].__resolveType = (parent: any) => resolveFromParentTypename(parent, schema);
}
});

Expand Down
8 changes: 2 additions & 6 deletions src/stitching/mergeSchemas.ts
Expand Up @@ -205,19 +205,15 @@ function recreateCompositeType(
...fieldMapToFieldConfigMap(fields, registry),
...createLinks(registry.getLinksByType(type.name), registry),
}),
resolveType: parent => resolveFromParentTypename(parent, schema),
resolveType: (parent, context, info) => resolveFromParentTypename(parent, info.schema),
});
} else {
return new GraphQLUnionType({
name: type.name,
description: type.description,
types: () =>
type.getTypes().map(unionMember => registry.resolveType(unionMember)),
resolveType: (parent, context, info) => {
const type = resolveFromParentTypename(parent, schema);
console.log('triple equal', type === schema.getType('Bike'), type === registry.resolveType(type));
return type;
},
resolveType: (parent, context, info) => resolveFromParentTypename(parent, info.schema),
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/test/testMergeSchemas.ts
Expand Up @@ -187,6 +187,7 @@ query {
`,
);

console.log(mergedResult.errors);
expect(mergedResult.errors).to.be.undefined;
expect(mergedResult).to.have.nested.property('data.firstProperty');
expect(mergedResult).to.have.nested.property('data.secondProperty');
Expand Down Expand Up @@ -225,7 +226,6 @@ query {
});

it('unions', async () => {
(mergedSchema.getType('Bike') as any)._fields.bikeType.resolve = (parent: any) => console.log('CALLED', parent);
const mergedResult = await graphql(
mergedSchema,
`
Expand All @@ -246,7 +246,6 @@ query {
`,
);

console.log(JSON.stringify(mergedResult));
expect(mergedResult.errors).to.be.undefined;
expect(mergedResult).to.have.nested.property('data.Booking_customerById');
expect(mergedResult).to.have.nested.property('data.Booking_customerById.vehicle');
Expand Down

0 comments on commit e65aa8a

Please sign in to comment.