https://github.com/plurid/dataql
Data Query Language and Service [Work in Thinking]
https://github.com/plurid/dataql
Last synced: 2 months ago
JSON representation
Data Query Language and Service [Work in Thinking]
- Host: GitHub
- URL: https://github.com/plurid/dataql
- Owner: plurid
- License: other
- Created: 2021-12-19T11:43:00.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-29T08:10:37.000Z (about 3 years ago)
- Last Synced: 2024-12-28T04:36:06.902Z (10 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.75 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
dataql
Data Query Language and Service`dataql` is a query language and service based on `datasign` and inspired by `GraphQL` and `TypeScript`.
### Contents
+ [About](#about)
+ [Packages](#packages)
+ [Codeophon](#codeophon)## About
A `dataql` server can be a `gateway` or a `service`. The `gateway` connects multiple `services`. A `service` has `signs` and `resolvers`. The `signs` contain `calls` and `types`. A `call` can be a `get`, a `set`, or a `net`. There is no technical difference between `get`, `set`, and `net`, but differentiating between them provides an well-abstracted access layer for the client: `get` for queries, `set` for mutations, `net` for subscriptions. A `type` is comprised of a `Name`, by convention `PascalCased`, and a record of `key primitive | Type` pairs. A `type` can also be composed from other types using `&`, for union, and `|`, for disunion, operators. The `primitives` are `string | number | boolean | void`.
``` dataql
// signs for an example service// simple call
getSomething(InputSomething): ResponseSomething// with input and response types
InputSomething {
someKey string | number | boolean
}ResponseSomething {
someOtherKey string | number | boolean
}// types
SomeType {
simpleKey string | number | boolean
nestedKey {
nestedNestedKey string | number | boolean
}
}SomeComposedType = SomeType & {
anotherKey string | number | boolean
}SomeDisjoinedType = {
aKey string | number | boolean
} | {
anotherKey string | number | boolean
}SomeDotComposedType {
someKey string | number | boolean
someOtherKey SomeComposedType.anotherKey
}SomeTypeWithOptionalKeys {
requiredKey string | number | boolean
optionalKey? string | number | boolean
anotherOptionalKey string | number | boolean | void
}SomeGenericType {
key T
}SomeImplementedType = SomeGenericType
SomeOtherImplementedType = SomeGenericType// calls
getSomething(InputGetSomething): ResponseGetSomething
setSomething(InputSetSomething): ResponseSetSomething
netSomething(InputNetSomething): ResponseNetSomethinggetSomethingWithNoInput(): ResponseGetSomething
setSomethingWithNoResponse(InputSetSomething): void
getSomethingWithInlineInput({
someKey primitive
}): ResponseGetSomething
```The `resolvers` are functions which receive `input` and `context` arguments.
``` typescript
const resolvers = {
someResolver: async (
input: any,
context: any,
) => {
const result = {
// data
};return result;
},
};
```A simple `dataql service` example
``` typescript
import express, {
Request,
Response,
} from 'express';
import {
generateService,
} from '@plurid/dataql-server';interface DataQLContext {
request: Request;
response: Response;
}const main = async () => {
const application = express();await generateService(
application,
{
signs: `
getProduct(InputGetProduct): ResponseGetProduct | void
setProduct(InputSetProduct): ResponseGetProductProduct {
id: string
name: string
price: number
}InputGetProduct = From<
Product,
id? | name?
>InputSetProduct = From<
Product,
name? | price?
>ResponseGetProduct = Product
`,
resolvers: {
getProduct: async (
input: { id?: string; name?: string; },
context: DataQLContext,
) => {
const {
id,
name,
} = input;if (id === 'one' || name === 'product') {
return {
id: 'one',
name: 'product',
price: 100,
};
}return;
},
setProduct: async (
input: { name?: string; price?: string; },
context: DataQLContext,
) => {
const {
name,
price,
} = input;return {
id: 'one',
name: name || 'product',
price: price || 100,
};
},
},
context: async (
request,
response,
) => {
return {
request,
response,
};
}
},
);app.listen(55443, () => {
console.log('dataql service on 55443');
});
}main();
```## Packages
[@plurid/dataql-client-javascript][dataql-client-javascript] • dataql JavaScript client
[dataql-client-javascript]: https://github.com/plurid/dataql/tree/master/packages/dataql-client/dataql-javascript
[@plurid/dataql-server-javascript][dataql-server-javascript] • dataql JavaScript server
[dataql-server-javascript]: https://github.com/plurid/dataql/tree/master/packages/dataql-server/dataql-javascript
## [Codeophon](https://github.com/ly3xqhl8g9/codeophon)
+ licensing: [delicense](https://github.com/ly3xqhl8g9/delicense)
+ versioning: [αver](https://github.com/ly3xqhl8g9/alpha-versioning)