question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Library not working if graphql files located in root directory

See original GitHub issue

Hi, 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:open
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Kiseprocommented, Nov 20, 2018

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 :

{
  "presets": ["module:metro-react-native-babel-preset"],
  "plugins": ["import-graphql"]
}
1reaction
detrohuttcommented, Nov 16, 2018

Thanks for reporting this, and for the easy repro instructions. I’ll try my best to check this out over the weekend!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found