Skip to content

Commit

Permalink
add explicit fieldNodes bare delegation test
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed May 17, 2020
1 parent 16eb45e commit 838f5be
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions packages/delegate/tests/createRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,72 @@ describe('bare requests', () => {
},
});

const outerSchema = makeExecutableSchema({
typeDefs: `
type Query {
delegate(input: String): String
}
`,
resolvers: {
Query: {
delegate: (_root, args) => {
const request = createRequest({
fieldNodes: [{
kind: Kind.FIELD,
name: {
kind: Kind.NAME,
value: 'delegate',
},
arguments: [{
kind: Kind.ARGUMENT,
name: {
kind: Kind.NAME,
value: 'input',
},
value: {
kind: Kind.STRING,
value: args.input,
}
}]
}],
targetOperation: 'query',
targetFieldName: 'test',
});
return delegateRequest({
request,
schema: innerSchema,
});
},
},
},
});

const result = await graphql(
outerSchema,
`
query {
delegate(input: "test")
}
`,
);

expect(result.data.delegate).toEqual('test');
});

test('should work with adding args on delegation', async () => {
const innerSchema = makeExecutableSchema({
typeDefs: `
type Query {
test(input: String): String
}
`,
resolvers: {
Query: {
test: (_root, args) => args.input
},
},
});

const outerSchema = makeExecutableSchema({
typeDefs: `
type Query {
Expand Down

0 comments on commit 838f5be

Please sign in to comment.