Library not working if graphql files located in root directory
See original GitHub issueHi, Thanks for your work.
I don’t know if you’re aware of it, but I lost a lot of time because of a very specific issue today. When the structure of your react-native project is the following :
./react-native-app/
./ios/
./android/
./node_modules/
./graphql/
./queries/
./query.graphql // <-- Trying to import this file
./App.js // <-- From this file, doing `import query from "./graphql/queries/query.graphql"`
It resulted every time in an error like :
build failed: couldn't find module "./graphql/queries/query.graphql"
But if I nest .js files in a /src/
directory, and the structure is like this :
./react-native-app/
./ios/
./android/
./node_modules/
./src/
./graphql/
./queries/
./query.graphql // <-- Trying to import this file
./App.js // <-- From this file, doing `import query from "./graphql/queries/query.graphql"`
Only then it works. And I’m aware that I have to remove the babel cache everytime I update something .graphql
related. You can reproduce this bug by simply creating a new project with :
1/ react-native init project
2/ Follow the instruction to install this library
3/ Create a dumb ./graphql/queries/query.graphql
4/ Try to import it from ./App.js
Regards.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using GraphQL with Python – A Complete Guide
We will make the following directory structure. The first file we'll start working with is the api/__init__.py file, which will hold all the...
Read more >A guide to the GraphQL Mesh library - LogRocket Blog
A guide to the GraphQL Mesh library · In the root directory of your project folder, create a file called · Let's start...
Read more >node.js - Yarn link: Importing graphql-js project into another ...
That error only occurs when there are multiple copies of graphql-js in your dependencies. Most commonly it's because there are multiple ...
Read more >Running an Express GraphQL Server
Running an Express GraphQL Server. The simplest way to run a GraphQL API server is to use Express, a popular web application framework...
Read more >How to Add File Upload to Your GraphQL API - Level Up Coding
File upload is a recent addition to GraphQL via libraries. ... Make a file called .babelrc in the root level of the back...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok for my part was because I had something wrong with my package and versions and in my .babelrc RN 57 requires to update few things like the preset “metro-react-native-babel-preset” instead of the deprecated one and it requires to change the .baberc like following :
Thanks for reporting this, and for the easy repro instructions. I’ll try my best to check this out over the weekend!