Created
April 18, 2020 07:46
-
-
Save andsens/2407142407bb9d3732bac0cf0ed8410b to your computer and use it in GitHub Desktop.
FragmentReference reproduce for relay-tools/relay-compiler-language-typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ComponentPaginationQuery } from "./artifacts/ComponentPaginationQuery.graphql"; | |
import { Component_items$key } from "./artifacts/Component_items.graphql"; | |
export function Component(props: { itemsFragment: Component_items$key }) { | |
const { | |
data: { items }, | |
} = usePaginationFragment<ComponentPaginationQuery, Component_items$key>( | |
graphql` | |
fragment Component_items on Viewer | |
@argumentDefinitions( | |
count: { type: "Int", defaultValue: 10 } | |
cursor: { type: "String" } | |
) | |
@refetchable(queryName: "ComponentPaginationQuery") { | |
items(first: $count, after: $cursor) | |
@connection(key: "ComponentEdge_items", filters: []) { | |
edges { | |
node { | |
id | |
} | |
} | |
} | |
} | |
`, | |
props.itemsFragment | |
); | |
return <div />; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"compile": "relay-compiler --language typescript --artifactDirectory artifacts --src . --schema schema.graphql" | |
}, | |
"dependencies": { | |
"graphql": "^15.0.0", | |
"relay-compiler": "^9.0.0", | |
"relay-compiler-language-typescript": "^12.0.0", | |
"typescript": "^3.8.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
viewer: Viewer! | |
} | |
interface Node { | |
id: ID! | |
} | |
type Viewer implements Node { | |
id: ID! | |
items(after: String, first: Int, before: String, last: Int): ItemConnection! | |
} | |
type ItemConnection { | |
pageInfo: PageInfo! | |
edges: [ItemEdge] | |
} | |
type PageInfo { | |
hasNextPage: Boolean! | |
hasPreviousPage: Boolean! | |
startCursor: String | |
endCursor: String | |
} | |
type ItemEdge { | |
node: Item | |
cursor: String! | |
} | |
type Item implements Node { | |
id: ID! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment