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

feat(cli): add support for reading schema from stdin in subgraph check command #1512

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

L42y
Copy link

@L42y L42y commented Jan 13, 2025

Motivation and Context

I want to introspect the schema then pipe to wgc for subgraph check without saving it to actual file first, as demonstrated in Apollo's Rover: https://www.apollographql.com/docs/rover/commands/subgraphs#subgraph-check

Checklist

  • I have discussed my proposed changes in an issue and have received approval to proceed.
  • I have followed the coding standards of the project.
  • Tests or benchmarks have been added or updated.
  • Documentation has been updated on https://github.com/wundergraph/cosmo-docs.
  • I have read the Contributors Guide.

@github-actions github-actions bot added the cli label Jan 13, 2025
@L42y L42y force-pushed the feat/wgc-subgraph-check-from-stdin branch from 58f14fa to 35b9825 Compare January 14, 2025 05:32
@@ -50,8 +47,27 @@ export default (opts: BaseCommandOptions) => {
});
}

// submit an empty schema in case of a delete check
const schema = schemaFile ? await readFile(schemaFile) : Buffer.from('');
// Handle schema input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@L42y the apollo approach in accepting the schema from stdin is unusual. Why should we use the --schema flag when piping data is already implicit? Additionally, --schema is declared as a way to specify a file path.

What do you think about this approach?

data | wgc subgraph check my-graph

This would follow the behaviour of common unix tools. An example to implement this is demonstrated here. This can be then also reused across all other commands.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think, I think both approaches has it's benefits.

Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants