podaac / swodlr

swodlr (swaa·dler) is a system for generating on demand raster products from SWOT L2 data
Apache License 2.0
4 stars 2 forks source link

Initial API Implementation #6

Closed joshgarde closed 1 year ago

joshgarde commented 1 year ago

A prototype implementation of the service's GraphQL API. Work done includes:

Example Requests:

Raster Definitions

Request:

{
    rasterDefinitions {
        id
    }
}

Response:

{
    "data": {
        "rasterDefinitions": [
            {
                "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
            }
        ]
    }
}

Create Product

Request:

mutation {
    createL2RasterProduct(definition: "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c") {
        id,
        definition {
            id
        },
        status {
            id,
            timestamp,
            status
        }
    }
}

Response:

{
    "data": {
        "createL2RasterProduct": {
            "id": "15e85ace-38d5-4ad5-b3d0-982042e81ebd",
            "definition": {
                "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
            },
            "status": [
                {
                    "id": "a8a71acf-f235-4b59-b308-77cc7fc4f4cf",
                    "timestamp": "2022-09-01 22:57:21.342991",
                    "status": "Initial creation"
                }
            ]
        }
    }
}

Current User with Products (w/o after Argument for Pagination)

Request:

{
    currentUser {
        id,
        products {
            id
            definition {
                id
            },
            status {
                timestamp,
                status
            }
        }
    }
}

Response:

{
    "data": {
        "currentUser": {
            "id": "fee1dc78-0604-4fa6-adae-0b4b55440e7d",
            "products": [
                {
                    "id": "15e85ace-38d5-4ad5-b3d0-982042e81ebd",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:21.342991",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "c56909b6-2c63-4746-bf9a-e6ce64d0d2fe",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:20.702051",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "b5dac5e9-ac70-4fd7-b7c7-d54ef58452d6",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:20.11137",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "2f5df7db-d0f0-4ede-be05-92d25c2ff653",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:19.531696",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "3b209a03-de0b-48b6-95b6-a63b5cd113c5",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:18.911966",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "ceae8849-2917-475b-aa0b-2361fd124c68",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:18.215138",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "c1fc06f5-ddc7-4c80-bc24-5412d77514cf",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:17.529521",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "4b18af67-9ae3-4a4c-8fde-c87e6d8855a4",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:16.871047",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "89fb7729-a228-4ccf-8ea3-defaec9fe409",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:16.171915",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "5bb32079-1b5b-4dc0-9ea3-3a128e2d0b03",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:15.438894",
                            "status": "Initial creation"
                        }
                    ]
                }
            ]
        }
    }
}

Current User with Products (w/ after Argument for Pagination)

Request:

{
    currentUser {
        id,
        products(after: "5bb32079-1b5b-4dc0-9ea3-3a128e2d0b03") {
            id
            definition {
                id
            },
            status {
                timestamp,
                status
            }
        }
    }
}

Response:

{
    "data": {
        "currentUser": {
            "id": "fee1dc78-0604-4fa6-adae-0b4b55440e7d",
            "products": [
                {
                    "id": "a0cc06cf-8634-459a-8bd5-db5d1a23388d",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:14.795785",
                            "status": "Initial creation"
                        }
                    ]
                },
                {
                    "id": "ced8dd43-c8e9-4203-8a00-2f86252e4816",
                    "definition": {
                        "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
                    },
                    "status": [
                        {
                            "timestamp": "2022-09-01 22:57:10.341486",
                            "status": "Initial creation"
                        }
                    ]
                }
            ]
        }
    }
}

Status (w/ product Argument)

Request

{
    statusByProduct(product: "15e85ace-38d5-4ad5-b3d0-982042e81ebd") {
        id
        status
    }
}

Response:

{
    "data": {
        "statusByProduct": [
            {
                "id": "a8a71acf-f235-4b59-b308-77cc7fc4f4cf",
                "status": "Initial creation"
            }
        ]
    }
}
frankinspace commented 1 year ago

First pass looks really good. Give me a bit to checkout the code and try to run it to get a better feel for it.

joshgarde commented 1 year ago

Per discussions, state enum + reason fields were added to the Status object.

New example requests look like this:


Create product

Request:

mutation {
    createL2RasterProduct(definition: "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c") {
        id,
        definition {
            id
        },
        status {
            id,
            timestamp,
            state,
            reason
        }
    }
}

Response:

{
    "data": {
        "createL2RasterProduct": {
            "id": "3ebb804f-6b6f-404d-98b9-89827bc21ce9",
            "definition": {
                "id": "a6d12de3-5f76-4e2d-9a42-1f2ab7f9ed7c"
            },
            "status": [
                {
                    "id": "02ea2973-7931-4092-b847-19968a473b28",
                    "timestamp": "2022-09-06 16:11:37.284498",
                    "state": "NEW",
                    "reason": null
                }
            ]
        }
    }
}

Status (w/ product argument)

Request:

{
    statusByProduct(product: "3ebb804f-6b6f-404d-98b9-89827bc21ce9") {
        id
        state
        reason
    }
}

Response:

{
    "data": {
        "statusByProduct": [
            {
                "id": "02ea2973-7931-4092-b847-19968a473b28",
                "state": "NEW",
                "reason": null
            }
        ]
    }
}