-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
RFC: simplify subgraph getting started and federation #10303
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a primitives PoV, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Now we can remove the touch command. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we initialize a The advantages of doing so are:
The only drawback is that we'll have 2 files that are the same except for the .env file. However since this is how it's done in all other cases and since this will eliminate the need to add an extra flag in all the commands, this seems like the more simpler approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IMO, this sounds like we are adding something to the subgraph. I feel like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's go with
This does not introduce additional subgraph.yaml files with no differences, but also makes the model clear to the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ddn subgraph add --supergraph The alternative here could be |
||
|
||
# create the supergraph build | ||
ddn supergraph build --supergraph supergraph.yaml --env-file app/.env.app.local | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In supergraph build, there could be multiple subgraphs and each can have its own env file. With this command, we cannot determine, which env file belongs to which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. Can we do Can do |
||
|
||
# deploy to cloud | ||
touch app/.env.app.cloud | ||
ddn connector build create --connector connector.yaml --target-env-file app/.env.app.cloud | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might not need a touch here. If the command is like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, can do without touch. Makes for better cross platform docs as well. |
||
``` | ||
|
||
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. | ||
|
||
```bash | ||
ddn connector init mydb --subgraph app/subgraph.yaml --hub-connector hasura/postgres | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These commands make sense. This would mean that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is breaking. Confirmed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to/ would it be possible to make it backwards compatible by allowing Not sure if any of this is worth it but just putting it out here for thought. |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we use I get that the subgraph mentioned here is the subgraph in the cloud project. If so, then should the flag be |
||
|
||
ddn connector build get --connector mypg/connector.yaml | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this command is run in a DDN project directory (where we can locate
hasura.yaml
)? Then we create theapp
directory at the root of the project? It would not make a lot of sense if the directory in created in the CWD. We should also think about the variant for federation use case, where we init a standalone subgraph (thus creatinghasura.yaml
,supergraph.local.yaml
, theglobals
directory, engine, docker-compose files etc)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's keep the existing behaviour of putting next to hasura.yaml.
Let's also introduce a --dir flag to explicitly give the directory like we do with connectors.