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

Does not work when relay config is not at vscode opened folder root #22

Open
janicduplessis opened this issue Sep 18, 2019 · 3 comments

Comments

@janicduplessis
Copy link
Contributor

janicduplessis commented Sep 18, 2019

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:

folderA:
  - apollo.config.js
  - relay.config.js
folderB:
  - apollo.config.js
  - relay.config.js

The issue is that relay-config expects cwd to contain a config file but in the context apollo.config.js is run it will be set to the root folder opened in vscode. As a workaround I changed my apollo.config.js to

process.chdir(__dirname);

const { config } = require('vscode-apollo-relay').generateConfig();

module.exports = config;

Not sure if we just want to change the documentation to this instead or find a better way to fix the issue.

@alloy
Copy link
Member

alloy commented Sep 20, 2019

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.

@acidoxee
Copy link

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 😕

@alloy
Copy link
Member

alloy commented Oct 25, 2019

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?

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

3 participants