relay-tools / found-relay

Relay integration for Found
MIT License
276 stars 32 forks source link

when using typescript, type for queries used in <Route path="path", Component={Component} query={query} /> are not generated at all #581

Closed achilsowa closed 3 years ago

achilsowa commented 3 years ago

Hi, I'm using create-react-app with typescript support I was looking for a static routing solution that I could use with relay modern, and I found found-relay (lol). Before using that, I was using a \<QueryRenderer \/> for final fetching of data to the server. With that queries and fragments type were generated in src/__generated__/typescript (my config folder in relay-compiler). Then I made some test with found-relay and tried to replace my \<QueryRenderer \/> with a makeConfigRoute like explained in the todomvc test code:

  1. fragment types (used with createFragmentContainer) still have their types generated correctly in src/__generated__/typescript
  2. But queries types, used in \<Route ...\/> (found/Route), and which were previously in \<QueryRenderer \/> are not, causing an error in my create react app typescript project to stop building process

I may be wrong, but due to point 2, I think the issue may be on the found-relay side, specially because everything worked fine with \<QueryRenderer \/>. I looks like relay-compiler seems to know nothing about \<Route \/> like he did for \<QueryRenderer \/>

Is there possible to "tell" that to relay-compiler ? Thanks

taion commented 3 years ago

relay-compiler doesn't look at either <QueryRenderer> or <Route> – it looks at the graphql tags. Are you still using those?

achilsowa commented 3 years ago

Hi, and thanks for your prompt reply.

relay-compiler doesn't look at either <QueryRenderer> or <Route> – it looks at the graphql tags. Are you still using those?

Yes I'am. Here is the essential content of my HomePage.graphql.ts that define the Home page query used later in <Route \>

import graphql from "babel-plugin-relay/macro"; export default graphql query Home_Query($first: Int, $after: String) { ...AnnounceList_data }

AnnounceList_data is a fragment created in createFragmentContainer, and after compiling with relay-compiler the file ./src/__generated__/typescript/AnnounceList_data.graphql.ts is generated but not the file ./src/__generated__/typescript/Home_Query.graphql.ts, which was generated before (when using <QueryRenderer />)

taion commented 3 years ago

Ah, I'm not really sure what's going on there, then. It's possible the plugin isn't correctly picking things up. Perhaps try inlining the graphql tag definition with the <Route>?

achilsowa commented 3 years ago

Hi @taion I tried to defined the graphql tag directly in the file it was used, and it was compiled. Thanks for your suggestions