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

Document .graphql and .gql file loading with graphql.macro #5481

Merged
merged 7 commits into from Apr 3, 2019

Conversation

@petetnt
Copy link
Collaborator

commented Oct 18, 2018

This PR follows up #3909 and #5076 by adding documentation for the .graphql loading features through babel-plugin-macros.

Signed-off-by: petetnt pete.a.nykanen@gmail.com

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 23, 2018

Target docusaurus docs instead of the old ones in the template/README.md
Signed-off-by: petetnt <pete.a.nykanen@gmail.com>

@petetnt petetnt force-pushed the petetnt:graphql-loader-docs branch from 67c3941 to 36353be Oct 23, 2018

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 23, 2018

Aaaand now it targets the docusaurus docs 🦎

sidebar_label: Loading .graphql Files
---

You can load `.gql` and `.graphql` files by using [`babel-plugin-macros`](https://github.com/kentcdodds/babel-plugin-macros) included with Create React App.

This comment has been minimized.

Copy link
@Timer

Timer Oct 24, 2018

Collaborator

Let's skip the part talking about macros and just combine these two sentences.

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 24, 2018

@Timer addressed comments, thanks!

@Timer

This comment has been minimized.

Copy link
Collaborator

commented Oct 24, 2018

Shouldn't this come right after Relay docs?

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 24, 2018

Adding loading other types of assets (images, svgs, styles...) are on that section and AFAIK the graphql-tag loading isn't applicable to Relay so it might be a confusing. Then again they are both graphql related so it might make sense to put it there too anyway (that's where I put it when I opened this PR).

Anyway is fine with me, you can take the pick 😄

@Timer Timer added this to the 2.1 milestone Oct 24, 2018

Alternatively you may use `yarn`:

```sh
yarn add graphql-tag.macro

This comment has been minimized.

Copy link
@AndresRodH

AndresRodH Oct 26, 2018

I think you meant graphql.macro rather than graphql-tag.macro here

This comment has been minimized.

Copy link
@petetnt

petetnt Oct 26, 2018

Author Collaborator

Thanks a ton @AndresRodH ! You are totally right, graphql.macro offers both the gql and the loader while graphql-tag only has the tag.

This comment has been minimized.

Copy link
@AndresRodH

AndresRodH Oct 26, 2018

You missed this one! 😆yarn add graphql.macro

This comment has been minimized.

Copy link
@petetnt

petetnt Oct 26, 2018

Author Collaborator

Hahaa 🤦‍♂️ maybe it's fixed now. I blame the GitHub editor and doing changes on the go 😂

petetnt added some commits Oct 26, 2018

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 26, 2018

Thanks @AndresRodH for reviewing!

@audiolion

This comment has been minimized.

Copy link

commented Oct 27, 2018

Just going to throw this out there, graphql.macro currently doesn't support absolute paths, if you have a monorepo setup where your .gql files are stored in another package like @app/graphql and yarn workspaces symlinks it into the CRA app's node_modules, graphql.macro won't find it.

I made a PR which adds support for this, but, it looks like babel-plugin-macros doesn't apply to imports from node_modules. I ultimately had to run @babel/cli with a proper .babelrc setup and import compiled files to get graphql support to work in 2.0 after graphql and monorepo support was removed.

I am also somewhat concerned because it does not look like the repository is being actively maintained, I made a fork with absolute path and node modules path support at @kimmel/graphql.macro to use for now with the hope that the maintainer will become active.

@Timer Timer modified the milestones: 2.1, 2.1.x Oct 28, 2018

donovantc and others added some commits Feb 14, 2019

Fix package name
Co-Authored-By: petetnt <pete.a.nykanen@gmail.com>
Fix another package name
Co-Authored-By: petetnt <pete.a.nykanen@gmail.com>
@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 14, 2019

Good catch @donovantc, fixed!

@petetnt

This comment has been minimized.

Copy link
Collaborator Author

commented Feb 14, 2019

It seems that @audiolion's comment has been addressed in graphql.macro so this can probably be safely merged.

@iansu iansu closed this Feb 16, 2019

@iansu iansu reopened this Feb 16, 2019

@iansu

This comment has been minimized.

Copy link
Collaborator

commented Feb 16, 2019

The deploy preview seems to be broken. Can you try rebasing with master to see if that fixes it?

@FredyC FredyC referenced this pull request Feb 23, 2019

Closed

Configurable `gql` import #1342

@iansu iansu modified the milestones: 2.1.x, 3.0 Mar 10, 2019

@iansu iansu added this to In progress in v3 Mar 10, 2019

@amyrlam amyrlam force-pushed the facebook:master branch from cecd762 to d3b19f9 Mar 24, 2019

@amyrlam amyrlam requested review from amyrlam and iansu as code owners Apr 3, 2019

@iansu

iansu approved these changes Apr 3, 2019

@amyrlam amyrlam changed the title Document .graphql and .gql file loading with graphql-tag.macro Document .graphql and .gql file loading with graphql.macro Apr 3, 2019

@amyrlam amyrlam merged commit d42f888 into facebook:master Apr 3, 2019

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
netlify/create-react-app/deploy-preview Docs deploy preview failed
Details

v3 automation moved this from In progress to Done Apr 3, 2019

@lock lock bot locked and limited conversation to collaborators Apr 8, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
8 participants
You can’t perform that action at this time.