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
Contributor

@petetnt petetnt 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
Copy link
Contributor Author

petetnt commented Oct 23, 2018

This should probably target the docs too https://github.com/facebook/create-react-app/blob/master/docusaurus/docs/

Signed-off-by: petetnt <pete.a.nykanen@gmail.com>
@petetnt
Copy link
Contributor Author

petetnt 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@petetnt
Copy link
Contributor Author

petetnt commented Oct 24, 2018

@Timer addressed comments, thanks!

@Timer
Copy link
Contributor

Timer commented Oct 24, 2018

Shouldn't this come right after Relay docs?

@petetnt
Copy link
Contributor Author

petetnt 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed this one! 😆yarn add graphql.macro

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@petetnt
Copy link
Contributor Author

petetnt commented Oct 26, 2018

Thanks @AndresRodH for reviewing!

@audiolion
Copy link

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 2 commits February 14, 2019 16:40
Co-Authored-By: petetnt <pete.a.nykanen@gmail.com>
Co-Authored-By: petetnt <pete.a.nykanen@gmail.com>
@petetnt
Copy link
Contributor Author

petetnt commented Feb 14, 2019

Good catch @donovantc, fixed!

@petetnt
Copy link
Contributor Author

petetnt 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
Copy link
Contributor

iansu commented Feb 16, 2019

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

@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
@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
None yet
Development

Successfully merging this pull request may close these issues.

8 participants