microsoft / graphitation

GraphQL tooling & runtime support needed for MS Teams and beyond
https://microsoft.github.io/graphitation/
MIT License
137 stars 30 forks source link

Add artifactDirectory option support to embedded-document-artefact-loader/ts-jest #414

Closed mwangi-njuguna closed 2 months ago

mwangi-njuguna commented 2 months ago

Adds support for explicitly passing artifactDirectory option in jest-config when using artifactDirectory in relay config.

alloy commented 2 months ago

@mwangi-njuguna Can you please elaborate on where/why you are using the artifactDirectory config? I understand what the config does in Relay, I contributed it, but I need to understand why we would need it inside MS?

Markionium commented 2 months ago

@alloy the reason we're currently using it is because of the following:

e.g. If my package is app-package and I run the relay compiler there, I don't want relay-compiler to write files into a dependency-package. So what we've done so is to use artifactDirectory to generate all the files for an app in 1JS inside the apps package and have webpack pick up the files from there using either @graphitation/embedded-document-artefact-loader/webpack or @swc/plugin-relay.

This has been working great so far for the app, but right now we're trying to fix up our tests and thus the reason for this PR :)

As an FYI, this isn't for Jana, we're using this for Org Explorer.

alloy commented 2 months ago

I'm worried about runtime values being imported from a centralised artefact directory with a manual written import, which then wouldn't work in a host app that doesn't use a centralised artefact directory.. I guess it should normally only be typings, so I'll approve this, but let's be mindful of that.