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

Syntax alternatives for DSL #86

Closed
3 tasks done
ralfhandl opened this issue Jul 9, 2020 · 2 comments
Closed
3 tasks done

Syntax alternatives for DSL #86

ralfhandl opened this issue Jul 9, 2020 · 2 comments
Assignees

Comments

@ralfhandl
Copy link
Contributor

ralfhandl commented Jul 9, 2020

Goal: provide syntax examples for the Jetson service below:

This is the service to model:
https://gist.github.com/wtrocki/0493510a85d1b65d12f3bfaf48d5629c

{
    "$Version": "4.0",
    "Jetsons.Models": {
        "company": {
            "$Kind": "EntityType",
            "$Key": [
                "stockSymbol"
            ],
            "stockSymbol": {},
            "name": {
                "$Nullable": true
            },
            "incorporated": {
                "$Type": "Edm.DateTimeOffset",
                "$Precision": 0
            },
            "employees": {
                "$Kind": "NavigationProperty",
                "$Collection": true,
                "$Type": "Jetsons.Models.employee",
                "$ContainsTarget": true
            }
        },
        "employee": {
            "$Kind": "EntityType",
            "$Key": [
                "id"
            ],
            "id": {
                "$Type": "Edm.Int32"
            },
            "firstName": {
                "$Nullable": true
            },
            "lastName": {
                "$Nullable": true
            },
            "title": {
                "$Nullable": true
            }
        },
        "youreFired": [
            {
                "$Kind": "Action",
                "$IsBound": true,
                "$Parameter": [
                    {
                        "$Name": "employee",
                        "$Type": "Jetsons.Models.employee",
                        "$Nullable": true
                    },
                    {
                        "$Name": "reason",
                        "$Unicode": false
                    }
                ]
            }
        ],
        "topEmployees": [
            {
                "$Kind": "Function",
                "$IsBound": true,
                "$Parameter": [
                    {
                        "$Name": "company",
                        "$Type": "Jetsons.Models.company",
                        "$Nullable": true
                    },
                    {
                        "$Name": "num",
                        "$Type": "Edm.Int32"
                    }
                ],
                "$ReturnType": {
                    "$Collection": true,
                    "$Type": "Jetsons.Models.employee"
                }
            }
        ],
        "Container": {
            "$Kind": "EntityContainer",
            "competitors": {
                "$Collection": true,
                "$Type": "Jetsons.Models.company"
            },
            "company": {
                "$Type": "Jetsons.Models.company"
            }
        }
    },
    "$EntityContainer": "Jetsons.Models.Container"
}
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Jetsons.Models">
      <EntityType Name="company">
        <Key>
          <PropertyRef Name="stockSymbol" />
        </Key>
        <Property Name="stockSymbol" Type="Edm.String" Nullable="false" />
        <Property Name="name" Type="Edm.String" />
        <Property Name="incorporated" Type="Edm.DateTimeOffset" Nullable="false" />
        <NavigationProperty Name="employees" Type="Collection(Jetsons.Models.employee)" ContainsTarget="true" />
      </EntityType>
      <EntityType Name="employee">
        <Key>
          <PropertyRef Name="id" />
        </Key>
        <Property Name="id" Type="Edm.Int32" Nullable="false" />
        <Property Name="firstName" Type="Edm.String" />
        <Property Name="lastName" Type="Edm.String" />
        <Property Name="title" Type="Edm.String" />
      </EntityType>
      <Action Name="youreFired" IsBound="true">
        <Parameter Name="employee" Type="Jetsons.Models.employee" />
        <Parameter Name="reason" Type="Edm.String" Nullable="false" Unicode="false" />
      </Action>
      <Function Name="topEmployees" IsBound="true">
        <Parameter Name="company" Type="Jetsons.Models.company" />
        <Parameter Name="num" Type="Edm.Int32" Nullable="false" />
        <ReturnType Type="Collection(Jetsons.Models.employee)" />
      </Function>
      <EntityContainer Name="Container">
        <EntitySet Name="competitors" EntityType="Jetsons.Models.company" />
        <Singleton Name="company" Type="Jetsons.Models.company" />
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>
@ralfhandl
Copy link
Contributor Author

ralfhandl commented Jul 9, 2020

Here's how it would look like in GraphQL-based RSDL. We probably would shorten @RapidX to just @X.

Note that @RapidAction on a query field is totally counter to GraphQL's strict separation of queries and mutations.

type company {
  stockSymbol: String! @RapidID
  name: String
  incorporated: DateTimeOffset!
  employees: [employee]
  topEmployees(num: Int32): [employee]
}

type employee {
  id: Int32! @RapidID
  firstName: String
  lastName: String
  title: String
  youreFired(reason: String) @RapidAction
}

type Query {
  company: company
  competitors: [company]
}

type Mutation {
  company: company @RapidUpdate
  competitors: company @RapidCreate @RapidUpdate @RapidDelete
}

@ralfhandl
Copy link
Contributor Author

Decision: use custom DSL prototyped by @chrisspre, see #91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants