For some days now, I am trying to use dynamic import for .graphql file without success.
I have defined a context provider using react to pass my apollo mutation dynamically based on route change.
const path = 'todo';
import(`@/ui/mutations/${path}.graphql`).then((mutations) =>
console.log('Mutations', mutations),
);
This returns
Uncaught Error: Cannot find module '@/ui/mutations/todo.graphql'
I have defined a whitelist file imported on both server and client with:
if (false) {
import("@/ui/mutations/todo.graphql");
...
}
I am using swydo:graphql@1.0.0
Has anyone succeded in doing something like this? Or are there any alternatives to this?