Skip to content

Commit b4099fc

Browse files
captbaritonefacebook-github-bot
authored andcommitted
Type bug with resolverDataInjector and resolvers that accept args
Differential Revision: D44921478 fbshipit-source-id: 32f1cd24db6d5cb21d42736daef6909e4d39e053
1 parent 5df8aee commit b4099fc

File tree

5 files changed

+385
-10
lines changed

5 files changed

+385
-10
lines changed

packages/react-relay/__tests__/RelayResolverModel-test.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const RelayNetwork = require('relay-runtime/network/RelayNetwork');
3131
const {graphql} = require('relay-runtime/query/GraphQLTag');
3232
const {
3333
addTodo,
34+
changeDescription,
3435
completeTodo,
3536
resetStore,
3637
} = require('relay-runtime/store/__tests__/resolvers/ExampleTodoStore');
@@ -279,6 +280,41 @@ describe.each([
279280
expect(renderer.toJSON()).toEqual('Test todo - green');
280281
});
281282

283+
test('read a field with arguments', () => {
284+
function TodoComponentWithFieldWithArgumentsComponent(props: {
285+
todoID: string,
286+
}) {
287+
const data = useClientQuery(
288+
graphql`
289+
query RelayResolverModelTestFieldWithArgumentsQuery($id: ID!) {
290+
todo_model(todoID: $id) {
291+
fancy_description {
292+
text_with_prefix(prefix: "[x]")
293+
}
294+
}
295+
}
296+
`,
297+
{id: props.todoID},
298+
);
299+
return data?.todo_model?.fancy_description?.text_with_prefix;
300+
}
301+
302+
addTodo('Test todo');
303+
304+
const renderer = TestRenderer.create(
305+
<EnvironmentWrapper environment={environment}>
306+
<TodoComponentWithFieldWithArgumentsComponent todoID="todo-1" />
307+
</EnvironmentWrapper>,
308+
);
309+
expect(renderer.toJSON()).toEqual('[x] Test todo');
310+
311+
TestRenderer.act(() => {
312+
changeDescription('todo-1', 'Changed todo description text');
313+
jest.runAllImmediates();
314+
});
315+
expect(renderer.toJSON()).toEqual('[x] Changed todo description text');
316+
});
317+
282318
test('read interface field', () => {
283319
function TodoComponentWithInterfaceComponent(props: {todoID: string}) {
284320
const data = useClientQuery(

packages/react-relay/__tests__/__generated__/RelayResolverModelTestFieldWithArgumentsQuery.graphql.js

Lines changed: 292 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)