Open janicduplessis opened 5 years ago
Hmm, good question. I don't have a similar setup and naively nothing comes to mind, so perhaps a mention in the README would at least be helpful for now–although a better solution would be nicer.
I'm having the same problem as @janicduplessis. It's not for a monorepo, but a common vscode workspace in which I have all the projects of my company.
The Apollo GraphQL extension logs display the following message:
Unable to load user's config from relay-config, so needs manual configuration.
{ client:
{ service: { name: 'local', localSchemaFile: './data/schema.graphql' },
validationRules:
[ [Function: RelayKnownArgumentNames],
[Function: RelayKnownVariableNames],
[Function: RelayVariablesInAllowedPosition],
[Function: RelayArgumentsOfCorrectType],
[Function: RelayDefaultValueOfCorrectType],
[Function: NoAnonymousQueries],
[Function: NoTypenameAlias],
[Function: ExecutableDefinitions],
[Function: UniqueOperationNames],
[Function: LoneAnonymousOperation],
[Function: SingleFieldSubscriptions],
[Function: KnownTypeNames],
[Function: FragmentsOnCompositeTypes],
[Function: VariablesAreInputTypes],
[Function: ScalarLeafs],
[Function: FieldsOnCorrectType],
[Function: UniqueFragmentNames],
[Function: KnownFragmentNames],
[Function: PossibleFragmentSpreads],
[Function: NoFragmentCycles],
[Function: UniqueVariableNames],
[Function: NoUnusedVariables],
[Function: KnownDirectives],
[Function: UniqueDirectivesPerLocation],
[Function: UniqueArgumentNames],
[Function: ValuesOfCorrectType],
[Function: ProvidedRequiredArguments],
[Function: OverlappingFieldsCanBeMerged],
[Function: UniqueInputFieldNames] ],
includes:
[ '/tmp/relay-compiler-directives-v5.0.0.graphql',
'src/**/*.{graphql,js,jsx}' ],
excludes: [],
tagName: 'graphql' } }
Error: Unable to read file ./data/schema.graphql. ENOENT: no such file or directory, open './data/schema.graphql'
The solution of using process.chdir(__dirname);
is indeed working. Problem is, if I open only the repo of my frontend, not the whole workspace, this obviously does not work anymore, and I need to remove that fix 😕
Under the hood relay-config
uses cosmiconfig, which I can imagine has already had to deal with this. Mind researching that a bit and report back with possible solutions?
I have a monorepo setup with multiple relay projects. I usually open vscode at the root of the repo. The apollo vscode project seem to handle multiple apollo.config.js files well but relay-config does not.
Setup looks like:
The issue is that relay-config expects
cwd
to contain a config file but in the contextapollo.config.js
is run it will be set to the root folder opened in vscode. As a workaround I changed my apollo.config.js toNot sure if we just want to change the documentation to this instead or find a better way to fix the issue.