The aim is to explore the possibilities of:
- Using the same model definition for both SQLAlchemy's ORM and the Strawberry GraphQL Schema
- Understand how to use GraphQL inputs consistently within the model
- How to implement pagination
- How to use efficient queries to avoid N+1 scenarios
- How to handle errors and their returns via GraphQL
This implements a very simple model. There is a Dataset which can contain zero to many Datafiles.
See the model/entity.py for details
- Create the poetry environment using your favourite shell/IDE
- In the terminal run
poetry run python -m strawberrysqlalchemy.mainor run main.py from your IDE
query MyQuery {
getDatasets {
name
retrievalUri
id
datafiles {
datasetId
filename
id
uri
}
}
}
mutation MyMutation {
addDataset(datasetInput: {name: "ds1", retrievalUri: "u1"}) {
id
}
}
mmutation MyMutation {
addDatafileToDataset(datafileInput: {filename: "fn", uri: "u"}, datasetId: 1) {
id
datafiles {
id
}
}
}