Skip to content

Commit

Permalink
Type bug with resolverDataInjector and resolvers that accept args
Browse files Browse the repository at this point in the history
Differential Revision: D44921478

fbshipit-source-id: 32f1cd24db6d5cb21d42736daef6909e4d39e053
  • Loading branch information
captbaritone authored and facebook-github-bot committed Apr 14, 2023
1 parent 5df8aee commit b4099fc
Show file tree
Hide file tree
Showing 5 changed files with 385 additions and 10 deletions.
36 changes: 36 additions & 0 deletions packages/react-relay/__tests__/RelayResolverModel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const RelayNetwork = require('relay-runtime/network/RelayNetwork');
const {graphql} = require('relay-runtime/query/GraphQLTag');
const {
addTodo,
changeDescription,
completeTodo,
resetStore,
} = require('relay-runtime/store/__tests__/resolvers/ExampleTodoStore');
Expand Down Expand Up @@ -279,6 +280,41 @@ describe.each([
expect(renderer.toJSON()).toEqual('Test todo - green');
});

test('read a field with arguments', () => {
function TodoComponentWithFieldWithArgumentsComponent(props: {
todoID: string,
}) {
const data = useClientQuery(
graphql`
query RelayResolverModelTestFieldWithArgumentsQuery($id: ID!) {
todo_model(todoID: $id) {
fancy_description {
text_with_prefix(prefix: "[x]")
}
}
}
`,
{id: props.todoID},
);
return data?.todo_model?.fancy_description?.text_with_prefix;
}

addTodo('Test todo');

const renderer = TestRenderer.create(
<EnvironmentWrapper environment={environment}>
<TodoComponentWithFieldWithArgumentsComponent todoID="todo-1" />
</EnvironmentWrapper>,
);
expect(renderer.toJSON()).toEqual('[x] Test todo');

TestRenderer.act(() => {
changeDescription('todo-1', 'Changed todo description text');
jest.runAllImmediates();
});
expect(renderer.toJSON()).toEqual('[x] Changed todo description text');
});

test('read interface field', () => {
function TodoComponentWithInterfaceComponent(props: {todoID: string}) {
const data = useClientQuery(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b4099fc

Please sign in to comment.