Comments (15)
@spiegela The only issue I bumped into using CRA with relay-compiler-language-typescript was setting the location of the artifacts directory. With the change I made, all I've had to do is add the following to my package.json:
"babelMacros": {
"relay": {
"artifactDirectory": "./src/__generated__"
}
}
(you can also configure this in other places according to your taste – more detail on that in the PR).
from relay-compiler-language-typescript.
can we close this?
check a working example here https://github.com/sibelius/create-react-app-relay-modern
from relay-compiler-language-typescript.
@spiegela by the way, even though my changes have been merged, there’s not been a release including them yet!
from relay-compiler-language-typescript.
If I exclude the artifacts in my .tsconfig, it works, but not sure if that's intended.
"exclude": [
"**/__generated__"
]
Sorry, new to typescript, let me know if I'm doing something stupid.
from relay-compiler-language-typescript.
I think #83 might solve the actual problem you're running into.
Besides that, here's a few notes:
Not using the single artifact directory should work just fine - but this will disable typechecking that the relay data you pass between components is actually correct (ie. you can now pass data to a component that has not had its data fetched). I understand the issue you run into here, but aside from working with the CRA team I'm not sure what we can do here.
Excluding the __generated__
directories from the TS compilation I would expect would stop the typechecker from working with those files. Can you import the files and get autocompletion in your components with this setup?
from relay-compiler-language-typescript.
I don’t have personal experience with CRA, but iirc there’s a project called babel-macros that would allow Babel configuration with CRA. (I don’t have fine to dive into that right now, but would welcome any patches necessary to make it work with that setup.)
from relay-compiler-language-typescript.
@kastermester You're correct that excluding the __generated__
directory broke autocompletion in my editor. I've reverted that change.
It looks like #83 hasn't been released yet, but I was able to get it working in the meantime by setting "noImplicitAny": false
in .tsconfig
. I recognize that this lowers the type-safety bar a bit.
@alloy Yes, we're using babel-plugin-relay/macro
. It sounds like the only change needed is to point it at a different artifact directory?
from relay-compiler-language-typescript.
Unsure. What I meant more is that if we can support CRA through Babel-macros (I don’t even know what they do exactly) then that would be great.
from relay-compiler-language-typescript.
Bumped into this problem myself today. I've opened a PR that allows you to configure babel-plugin-relay options through the macro, but it's a change that has to be made on the plugin itself: facebook/relay#2646
from relay-compiler-language-typescript.
@sgwilym It looks like your change to configure babel-plugin-relay/macro
got merged. Do you have an example of this with relay-compiler-language-typescript
? I'm also running into issues with a CRA-2 app.
from relay-compiler-language-typescript.
You’re not actually using these settings in that example app, right? In any case, yeah feels like we can close this by now 👍
from relay-compiler-language-typescript.
Well, I checked the sample app, and it doesn't seem to relate to this issue. I know I came in late on this issue, but I'm experiencing the same result. However, this doesn't seem to be an issue with relay-compiler-language
, rather I haven't gotten babel-plugin-relay/macro
to recognize my artifactDirectory
setting, yet-- I've tried various methods described in the links above.
I'll take this up with babel-plugin-relay
, but out of curiosity is there a hard dependency for relay-compiler-language
on a specific artifactDirectory
for the generated ts files? My issue would also be solved if the default behavior of babel-plugin-relay/macro
matched the default behavior of relay-compiler
: placing the generated files in __generated__
directories in the same directory as the source file.
from relay-compiler-language-typescript.
@spiegela Thanks for the update! @sibelius Any chance you could update your example to use these macro settings?
As for the other question, please see this section of the type emission part of the Relay docs: https://facebook.github.io/relay/docs/en/type-emission.html#single-artifact-directory
from relay-compiler-language-typescript.
🤦♂️ Of course! I don't know why I didn't check to see if it was in a release. I'll take a look and see if I can test with babel-plugin-relay
from master.
from relay-compiler-language-typescript.
Fix graphql errors with this
DefinitelyTyped/DefinitelyTyped#35707
from relay-compiler-language-typescript.
Related Issues (20)
- Generated refetch definition with variables can not pass the validation of backend, such as github.com/vektah/gqlparser/v2
- Generate GraphQL fragment files for VSCode GraphQL Extension fragment autocompletion HOT 2
- Cannot read property 'createKeywordTypeNode' of undefined HOT 8
- Support for [email protected] HOT 8
- Migrate travis CI release process to GitHub actions HOT 3
- Unknown directive 'appendNode' HOT 1
- module esnext HOT 2
- Why is it not releasing HOT 7
- `require` substitution is not working HOT 6
- doc: explain why configuration with a single artifact directory is suggested
- Update to TS 4.4 and update types to support exactOptionalPropertyTypes HOT 1
- @stream argument naming by schema spec is: `initialCount` not `initial_count` HOT 1
- Invalid AST Node error with graphql@16 HOT 2
- Typescript 4.5 type generation is broken HOT 6
- Relay Compiler generates Typescript Synthax error HOT 3
- Error: Cannot find module 'relay-compiler-language-typescript' on 15.0
- Fragment Typematching
- Input Types generated as readonly HOT 1
- deprecate this package HOT 1
- Issue with import of the __generated__
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relay-compiler-language-typescript.