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

Compiler fails if there are two fragments in a single file #340

Closed
sjwilczynski opened this issue Jul 25, 2023 · 2 comments
Closed

Compiler fails if there are two fragments in a single file #340

sjwilczynski opened this issue Jul 25, 2023 · 2 comments

Comments

@sjwilczynski
Copy link
Contributor

On https://github.com/sjwilczynski/graphitation/tree/user/stwilczy/fragmentRepro I added another fragment to two components in apollo-watch-fragments example. They mimic setup we have in 1JS, where we very often have more than one fragment (view data and domain data, and sometimes even another domain data one). In such case even if the fragment is very simple compiler fails with:

➜  apollo-watch-fragments (user/stwilczy/fragmentRepro) yarn duct-tape-compiler
yarn run v1.22.15
$ duct-tape-compiler --schema ./data/schema.graphql --src ./src --emitQueryDebugComments

Writing ts
DeprecationWarning: 'createTypeAliasDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an 
overload that does not accept a 'decorators' parameter.
DeprecationWarning: 'createImportDeclaration' has been deprecated since v4.8.0. Decorators are no longer supported for this function. Callers should switch to an ove
rload that does not accept a 'decorators' parameter.
ERROR:
Error writing modules:
Invariant Violation: Expected to find a @refetchable directive on TodoList_viewDataFragment
    at invariant (C:\Users\stwilczy\Repos\graphitation\node_modules\invariant\invariant.js:40:15)
    at printWatchNodeQueryReExport (C:\Users\stwilczy\Repos\graphitation\packages\apollo-react-relay-duct-tape-compiler\src\formatModule.ts:118:12)
    at C:\Users\stwilczy\Repos\graphitation\packages\apollo-react-relay-duct-tape-compiler\src\formatModule.ts:98:33
    at C:\Users\stwilczy\Repos\graphitation\node_modules\relay-compiler\lib\codegen\writeRelayGeneratedFile.js:153:22
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\stwilczy\Repos\graphitation\node_modules\@babel\runtime\helpers\asyncToGenerator.js:3:24)
    at _next (C:\Users\stwilczy\Repos\graphitation\node_modules\@babel\runtime\helpers\asyncToGenerator.js:25:9)
    at C:\Users\stwilczy\Repos\graphitation\node_modules\@babel\runtime\helpers\asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at C:\Users\stwilczy\Repos\graphitation\node_modules\@babel\runtime\helpers\asyncToGenerator.js:21:12
error Command failed with exit code 100.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@sjwilczynski
Copy link
Contributor Author

@alloy in latest commit to linked branch I added all the things that I was able to found. I wasn't able to write unit tests as I don't know compiler or duct tape code well enough but I pushed changes to schema in apollo-watch-fragments example with issue. To allow you to easier navigate, I added for each issue a comment in code like [issue 1]: .... which is either immediately seen at app runtime or triggered by uncommenting/adjusting fragment

@sjwilczynski
Copy link
Contributor Author

Fixed by #341

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

No branches or pull requests

1 participant