From a9cd1167ad1e8d51b6c22444c45b8fe30fd57a62 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 3 Mar 2020 20:02:52 +1100 Subject: [PATCH] Moved notes.md to README.md --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/notes.md | 49 ------------------------ 2 files changed, 102 insertions(+), 49 deletions(-) create mode 100644 README.md delete mode 100644 docs/notes.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f114025 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +simpleQL is a web API query language that mimics graphQL, designed solely for fun. + +simpleQL consists of two languages - the schema language, and the query language. + +## The Schema Language + +The schema language is a layout of how queries should be made, as well as what can be made with them. There are two built-in keywords for the schema language: + +* type +* scalar + +`type` is used for defining new compound types. `scalar` is for defining new scalar types, such as `Date`. + +The built-in types for the schema language are: + +* String +* Integer +* Float +* Boolean + +These can be combined into compound types as so: + +``` +scalar Date + +type Book { + String title + Author author + Date published +} + +type Author { + !String name + !Book[] books +} +``` + +`[]` Represents an array of fields, while `!` represents a field that must not be omitted in queries (non-nullable). + +## The Query Language + +The query langauge can be used to request data from a server, either in whole or in part by listing it's type and it's fields, and subfields. + +``` +Book { + title + author { + name + books { + title + } + } +} +``` + +The fields can be altered as well, using the query language's built-in keywords: + +* create +* update +* delete +* match +* set + +`create`, `update` and `delete` do as you would expect them to. + +When using `create`, `match` will find an existing record for a compound type and use that as it's value (multiple matches is an error): + +``` +create Book { + set title "The Wind in the Willows" + match author { + name "Kenneth Grahame" + } +} +``` + +When using `update`, `match` will find all existing records and update those using the `set` keyword: + +``` +update Book { + match title "The Wind in the Willows" + set published "15 June 1908" +} +``` + +``` +update Book { + match title "The Wind in the Willows" + set title "The Fart in the Fronds" +} +``` + +When using `delete`, only `match` is valid, and will delete all matching records: + +``` +delete Book { + match title "The Fart in the Fronds" +} +``` + +You can use as many instances of `match` and `set` as you like, as long as the result is valid. + diff --git a/docs/notes.md b/docs/notes.md deleted file mode 100644 index 8220b5d..0000000 --- a/docs/notes.md +++ /dev/null @@ -1,49 +0,0 @@ -simpleQL is a web API query language that mimics graphQL, designed solely for fun. - -simpleQL consists of two languages - the schema language, and the query language. The schema language is a layout of how queries should be made, as well as what can be made with them. - -There are two built-in keywords for the schema language: - -* type -* scalar - -`type` is used for defining new compound types. `scalar` is for defining new scalar types, such as `Date`. - -The built-in types for the schema language are: - -* String -* Integer -* Float -* Boolean - -These can be combined into compound types as so: - -``` -scalar Date - -type Book { - String title - Author author - Date published -} - -type Author { - !String name - !Book[] books -} -``` - -The query langauge can be used to request data from a server, either in whole or in part by listing it's type and it's fields, and subfields. - -``` -Book { - title - author { - name - books { - title - } - } -} -``` -