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

Move check for graphql string in source files to language plugin #2811

Closed

Conversation

zth
Copy link
Contributor

@zth zth commented Jul 31, 2019

This moves the check for the string graphql in source files to the JS language plugin, away from RelaySourceModuleParser. This has two reasons:

  1. Language plugins might not require/use the string 'graphql'. I have that case when emitting ReasonML types - Writing GraphQL there looks like [%relay.mutation ...] and [%relay.query ...], so graphql is not naturally inside any of the source files I want the compiler to pick up.
  2. The requirement was quite "hidden" and it took me a few hours to understand why my files weren't picked up even though they seemed to satisfy all requirements of the compiler + configuration. So, also reducing confusion.

If this lands I'll PR the TypeScript language plugin to add the same type of check into that as well.

zth added 3 commits July 31, 2019 19:45
…there are no additional checks done on the file content.
… JS language plugin where we know 'graphql' must be in the source for it to contain graphql tags.
@jstejada
Copy link
Contributor

jstejada commented Aug 7, 2019

cc @alunyov or @kassens might want to take a look at this

Copy link
Member

@kassens kassens left a comment

Choose a reason for hiding this comment

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

The language plugin already provides the findGraphQLTags function here:

https://github.com/facebook/relay/blame/master/packages/relay-compiler/bin/RelayCompilerMain.js#L279

What do you think of adding the getFileFilter function there as well?

This "early filter" was helping in reducing the number of files we keep track of in watch mode, skipping quickly over all the non-relay related files.

@zth
Copy link
Contributor Author

zth commented Aug 8, 2019

Hey @kassens ,

I think that sounds good! I made some changes - is this more in line of what you had in mind?

@zth zth requested a review from kassens September 23, 2019 07:09
@zth
Copy link
Contributor Author

zth commented Feb 12, 2020

cc @alunyov since you're on a merging spree ;) Would you mind having a look at this one too?

It's the last piece of the puzzle to make the compiler to support what I need for making my Reason integration work without needing to maintain a fork.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@alunyov has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@alunyov merged this pull request in 79ff0b0.

jstejada pushed a commit that referenced this pull request Feb 13, 2020
Summary:
This moves the check for the string `graphql` in source files to the JS language plugin, away from `RelaySourceModuleParser`. This has two reasons:

1. Language plugins might not require/use the string 'graphql'. I have that case when emitting ReasonML types - Writing GraphQL there looks like `[%relay.mutation ...]` and `[%relay.query ...]`, so `graphql` is not naturally inside any of the source files I want the compiler to pick up.
2. The requirement was quite "hidden" and it took me a few hours to understand why my files weren't picked up even though they seemed to satisfy all requirements of the compiler + configuration. So, also reducing confusion.

If this lands I'll PR the TypeScript language plugin to add the same type of check into that as well.
Pull Request resolved: #2811

Reviewed By: jstejada

Differential Revision: D19856119

Pulled By: alunyov

fbshipit-source-id: 864c75020db6993b0a3702c38a8ab22b7933073a
@mrtnzlml
Copy link
Contributor

If this lands I'll PR the TypeScript language plugin to add the same type of check into that as well.

Hi @zth, I just wanted to remind you of this. Do you have time to update the TS language plugin? :)

@zth
Copy link
Contributor Author

zth commented Feb 18, 2020

@mrtnzlml I actually believe this PR was changed enough from its original state that the TS plugin won't need PRing. Or have you encountered a bug because of this?

@zth zth deleted the remove-graphql-string-in-source-requirement branch February 18, 2020 17:48
@mrtnzlml
Copy link
Contributor

I thought so, but I was mistaken - it was a different issue. Sorry for the useless ping. 😬

@zth
Copy link
Contributor Author

zth commented Feb 19, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants