From 7ab3fa5a13675fa30423d3aa80f06c2fd5e83c09 Mon Sep 17 00:00:00 2001 From: Akshaya Acharya Date: Thu, 20 Jun 2024 19:09:17 +0530 Subject: [PATCH 1/2] 20240620-simplify-subgraph-getting-started-and-federation --- ...subgraph-getting-started-and-federation.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md diff --git a/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md b/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md new file mode 100644 index 0000000000000..e06939e34b05d --- /dev/null +++ b/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md @@ -0,0 +1,40 @@ +# DX: simplify subgraphs for getting started and federation workflows + +Status: Review required + +## subgraph init command +What this is: as a part of making it easier for people to work through the getting started guide, or to scaffold project files, allow the user to go from scratch to an API with only CLI commands. + +init-ing a supergraph or connector will create files for both local and cloud environments. This is about what happens for the subgraphs. + +```bash +# creates a subgraph folder and subgraph.yaml file +ddn subgraph init app + +# add subgraph.yaml to the supergraph.yaml file and create an env file for the env +ddn supergraph add subgraph --supergraph supergraph.local.yaml --subgraph app/subgraph.yaml +touch app/.env.app.local + +# create the supergraph build +ddn supergraph build --supergraph supergraph.yaml --env-file app/.env.app.local + +# deploy to cloud +touch app/.env.app.cloud +ddn connector build create --connector connector.yaml --target-env-file app/.env.app.cloud +``` + +## --subgraph flag should take the file name + +What this is about: on introducing federation, we realize that the primitive is the subgraph not the supergraph. The following commands are updated to consider the subgraph.yaml file instead of specifying a supergraph.yaml file and the subgraph by name. + +```bash +ddn connector init mydb --subgraph app/subgraph.yaml --hub-connector hasura/postgres + +ddn connector build create --connector mydb/connector.yaml --target-env-file app/.env.app.cloud + +ddn model add --subgraph app/subgraph.yaml --connector-link mydb --name Album + +ddn connector build get --connector-name mypg --subgraph-name app --project proj-1234 + +ddn connector build get --connector mypg/connector.yaml +``` From 89495d5e7239ceb81fe8c22889449ce68581ca5c Mon Sep 17 00:00:00 2001 From: Akshaya Acharya Date: Thu, 20 Jun 2024 20:01:31 +0530 Subject: [PATCH 2/2] Clarify details on env overrides and target flags --- ...implify-subgraph-getting-started-and-federation.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md b/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md index e06939e34b05d..dcc7dc61e6562 100644 --- a/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md +++ b/v3/rfcs/dx/20240620-simplify-subgraph-getting-started-and-federation.md @@ -23,6 +23,11 @@ touch app/.env.app.cloud ddn connector build create --connector connector.yaml --target-env-file app/.env.app.cloud ``` +Order of env +- specify either as --env flags or --env-file flags, which can be specified multiple times +- all flags override the env specified in the subgraph.yaml file +- later flags override earlier flags + ## --subgraph flag should take the file name What this is about: on introducing federation, we realize that the primitive is the subgraph not the supergraph. The following commands are updated to consider the subgraph.yaml file instead of specifying a supergraph.yaml file and the subgraph by name. @@ -30,11 +35,13 @@ What this is about: on introducing federation, we realize that the primitive is ```bash ddn connector init mydb --subgraph app/subgraph.yaml --hub-connector hasura/postgres -ddn connector build create --connector mydb/connector.yaml --target-env-file app/.env.app.cloud +ddn connector build create --connector mydb/connector.yaml --target-subgraph app/subgraph.yaml --target-connector-link mypg # use env file from subgraph.yaml + +ddn connector build create --connector mydb/connector.yaml --target-subgraph app/subgraph.yaml --target-connector-link mypg --target-env-file app/.env.app.cloud ddn model add --subgraph app/subgraph.yaml --connector-link mydb --name Album ddn connector build get --connector-name mypg --subgraph-name app --project proj-1234 ddn connector build get --connector mypg/connector.yaml -``` +``` \ No newline at end of file