From 4c5cd416e041f8bae7256eaee4e703514371bc41 Mon Sep 17 00:00:00 2001 From: Andrey Lunyov Date: Tue, 4 Jun 2024 14:20:56 -0700 Subject: [PATCH] Add docs for `preferFetchable` argument Reviewed By: antoinebrault Differential Revision: D58152287 fbshipit-source-id: 142e6685698ca6632744c3151d99851ad11338b1 --- website/docs/api-reference/graphql/graphql-directives.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/website/docs/api-reference/graphql/graphql-directives.md b/website/docs/api-reference/graphql/graphql-directives.md index 35eb69e3435e7..3450d789224ca 100644 --- a/website/docs/api-reference/graphql/graphql-directives.md +++ b/website/docs/api-reference/graphql/graphql-directives.md @@ -110,12 +110,16 @@ Notes: With `usePaginationFragment`, Relay expects connection fields to be annotated with a `@connection` directive. For more detailed information and an example, check out the [docs on `usePaginationFragment`](../../guided-tour/list-data/rendering-connections). -## `@refetchable(queryName: String!, directives: [String])` +## `@refetchable(queryName: String!, directives: [String], preferFetchable: Boolean)` With `useRefetchableFragment` and `usePaginationFragment`, Relay expects a `@refetchable` directive. The `@refetchable` directive can only be added to fragments that are "refetchable", that is, on fragments that are declared on `Viewer` or `Query` types, or on a type that implements `Node` (i.e. a type that has an id). The `@refetchable` directive will autogenerate a query with the specified `queryName`. This will also generate Flow types for the query, available to import from the generated file: `.graphql.js`. For more detailed information and examples, check out the docs on [`useRefetchableFragment`](../use-refetchable-fragment/) or [`usePaginationFragment`](../use-pagination-fragment/). Optionally, you can pass in a list of directives to add to the autogenerated query. For example, this can be used to add the `@relay_test_operation` directive for [testing](../../guides/testing-relay-components): +[Optional] `preferFetchable: Boolean` + +This argument tells the Relay compiler to prefer generating `fetch_MyType(): MyType` queries for types that implement the `Node` interface. This is useful for schemas that have adopted the `@strong` and `@fetchable` server annotations for types. You can directly fetch concrete objects without needing to refine `Node` interface to a specific type. + ```javascript graphql` fragment FriendsListComponent_user on User