Skip to content

Commit

Permalink
rebase, update test and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdstock committed Feb 4, 2021
1 parent fccb599 commit feaf75b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/stitching/exchange/__tests__/stitching.test.ts
Expand Up @@ -137,7 +137,7 @@ it("delegates to the local schema for an Order's creditCard", async () => {

expect(mergeInfo.delegateToSchema).toHaveBeenCalledWith({
args: { id: "CC-1" },
fieldName: "credit_card",
fieldName: "creditCard",
...restOfResolveArgs,
})
})
Expand All @@ -151,7 +151,7 @@ it("doesn't delegate to the local schema for an Order's creditCard if creditCard

expect(mergeInfo.delegateToSchema).not.toHaveBeenCalledWith({
args: { id: null },
fieldName: "credit_card",
fieldName: "creditCard",
...restOfResolveArgs,
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stitching/exchange/__tests__/testingUtils.ts
@@ -1,8 +1,8 @@
import { mergeSchemas } from "graphql-tools"
import { exchangeStitchingEnvironment } from "../v1/stitching"
import { exchangeStitchingEnvironment } from "../v2/stitching"
import { GraphQLSchema } from "graphql"
import { executableExchangeSchema, transformsForExchange } from "../schema"
import localSchema from "schema/v1/schema"
import localSchema from "schema/v2/schema"

let cachedSchema: GraphQLSchema & { transforms: any }
let stitchedSchema: ReturnType<typeof exchangeStitchingEnvironment>
Expand Down
11 changes: 7 additions & 4 deletions src/lib/stitching/exchange/v2/stitching.ts
Expand Up @@ -366,8 +366,9 @@ export const exchangeStitchingEnvironment = ({
try {
await conversationLoader(impulseConversationId)
} catch (e) {
// be more elegant?
throw new GraphQLError(`Bad Request`)
throw new GraphQLError(
`[metaphysics @ exchange/v2/stitching] Conversation not found`
)
}

const offerResult = await info.mergeInfo.delegateToSchema({
Expand Down Expand Up @@ -415,7 +416,9 @@ export const exchangeStitchingEnvironment = ({
} = orderOrError

if (!orderId) {
throw new GraphQLError("Bad request (no order id)")
throw new GraphQLError(
"[metaphysics @ exchange/v2/stitching] Order.orderID field must be selected"
)
}

try {
Expand All @@ -425,7 +428,7 @@ export const exchangeStitchingEnvironment = ({
})
} catch (e) {
throw new GraphQLError(
"Impulse: request to associate offer with conversation failed"
"[metaphysics @ exchange/v2/stitching] Impulse: request to associate offer with conversation failed"
)
}
}
Expand Down

0 comments on commit feaf75b

Please sign in to comment.