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

Rework transformed query output to include separate fragments #1631

Merged
merged 4 commits into from Sep 27, 2019

Conversation

DSteve595
Copy link
Contributor

I made a mistake thinking sourceWithFragments was the __typename-ified version of the document, while source wasn't.
source actually does have the __typenames added.
Including the fragments in the transformed queries actually opens up potential problems for the workflow I described in #1597 (and likely the workflow in #1607), because APIs that required persisted operations but don't support APQ generally still follow the queries/+mutations/+fragments/ pattern, and expect fragments to still be separated as they are in the developer-facing source.
This changes TransformedQueryOutput to save the transformed operations and transformed fragments separately, as they exist in the source. Fragments that are defined in operations (e.g. query MyQuery { ...MyFragment } fragment MyFragment { } are appended to the operation's file, resulting in no changes other than the addition of __typenames.
Also, no longer using packageNameProvider to get the destinations for these files, since those are more intended for Java/Kotlin source.

transformedDocuments = transformedDocuments + ir.fragments.map { fragment ->
TransformedDocument(
document = fragment.source,
filePath = fragment.filePath!!.relativePathToGraphql()!!
Copy link
Contributor Author

@DSteve595 DSteve595 Sep 26, 2019

Choose a reason for hiding this comment

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

When would fragment.filePath be null? I can't find any repro cases

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it left from old code gen, feel free to make it non-optional

@DSteve595
Copy link
Contributor Author

^ force-push was a no-op, checking to see if that build failure is reproducible

@sav007 sav007 merged commit 18bfeb2 into apollographql:master Sep 27, 2019
@DSteve595 DSteve595 deleted the transformed-queries-source branch October 7, 2019 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants