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.

Consider decoupling CRA 2.0 from graphql-tag version

See original GitHub issue

#3909 added support for importing *.graphql files. This is only useful for GraphQL libraries that want to consume the AST from the graphql package at the particular version bundled with CRA. This ties the upgrade of graphql and CRA together which seems limiting.

Relay (which doesn’t import GraphQL, but instead uses inline GraphQL) solves this in the next version by supporting babel-plugin-macros which will look similar to:

import graphql from 'babel-plugin-relay/macro';
graphql`fragment Test on User { name }`

I’m not sure if loaders could be made ‘injectable’ in some way, but decoupling the projects might make upgrades easier going forward.

I want to add that keeping *.graphql require support specific to Apollo doesn’t get in the way of Relay’s solution.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
iansucommented, Aug 16, 2018

Is there something similar to graphql-tag/loader that’s implemented using babel-plugin-macro? If so that might be a better way forward. That way the approach would be similar for Relay and Apollo and we wouldn’t be tying people to a specific version of graphql-tag.

0reactions
Timercommented, Sep 24, 2018

Was the general consensus here that we revert #3909?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiling queries with Babel - Apollo GraphQL Docs
This approach will allow you to use the graphql-tag library as usual, and when processing the files with this babel plugin, the calls...
Read more >
From a Single Repo, to Multi-Repos, to Monorepo, to Multi ...
The monorepo is a single repo that hosts the code for multiple projects. Since it hosts different packages together, we can version control...
Read more >
graphql-tag - npm
A JavaScript template literal tag that parses GraphQL queries. Latest version: 2.12.6, last published: a year ago. Start using graphql-tag ...
Read more >
PickBazar - React Ecommerce Template with ... - ThemeForest
Buy PickBazar - React Ecommerce Template with React Hooks, Next JS, GraphQL & REST API by redqteam on ThemeForest. Our super-fast E-commerce ...
Read more >
Loading .graphql Files - Create React App
To load .gql and .graphql files, first install the graphql and ... use the non-macro version from graphql-tag package with the added benefit ......
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