Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
achilsowa opened this issue Dec 17, 2020 · 4 comments

Comments

@achilsowa
Copy link

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
Copy link
Member

taion commented Dec 17, 2020

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

@achilsowa
Copy link
Author

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
Copy link
Member

taion commented Dec 18, 2020

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants