Skip to content

[Bug] relay-compiler --validate shouldn't require persistConfig url to be running #5007

@aryaniyaps

Description

@aryaniyaps
Contributor

this is my relay.config.json file:

{
	"src": "./",
	"language": "typescript",
	"schema": "../../schema/schema.graphql",
	"artifactDirectory": "./__generated__",
	"excludes": ["**/node_modules/**", "**/__mocks__/**", "**/__tests__/**"],
	"useImportTypeSyntax": true,
	"persistConfig": {
		"url": "http://localhost:2999",
		"includeQueryText": false,
		"concurrency": 1
	},
}

when I run the relay-compiler --validate command and there are no changes to the artifacts to be built, everything is working fine.

But when there is a change- I get this error:

➜  accounts (main) relay-compiler --validate                                                                                                                                                                                                                      ✭
[INFO] Querying files to compile...
[INFO] [default] compiling...
[ERROR] Error: Network error: error trying to connect: tcp connect error: Connection refused (os error 111)
[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details: 
Failed to build:
 - Persisting operation(s) failed:
 - Network error: error trying to connect: tcp connect error: Connection refused (os error 111)

this is because I run a local persisting server.

This is an issue especially during CI checks where it doesn't make sense to run this type of server.

Ideally the command should just error out without the network error.

Activity

changed the title [-]relay-compiler --validate shouldn't require persistConfig url to be running[/-] [+][Bug] relay-compiler --validate shouldn't require persistConfig url to be running[/+] on May 24, 2025
captbaritone

captbaritone commented on May 30, 2025

@captbaritone
Contributor

It sounds sensible on its face. You could try changing this code so that we don't set the persister if we are in validate mode.

if command.validate {
config.artifact_writer = Box::<ArtifactValidationWriter>::default();
}
config.create_operation_persister = Some(Box::new(|project_config| {
project_config.persist.as_ref().map(
|persist_config| -> Box<dyn OperationPersister + Send + Sync> {
match persist_config {
PersistConfig::Remote(remote_config) => {
Box::new(RemotePersister::new(remote_config.clone()))
}
PersistConfig::Local(local_config) => {
Box::new(LocalPersister::new(local_config.clone()))
}
}
},
)
}));

I don't think we have bandwidth to work on this, but if you can open a PR that does not add much complexity we'd be open to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @captbaritone@facebook-github-bot@aryaniyaps

      Issue actions

        [Bug] relay-compiler --validate shouldn't require persistConfig url to be running · Issue #5007 · facebook/relay