- SQL autocomplete to be used with parsed db schema from a subgraph via graph-tables.
- Supports incomplete SQL
- Supports table and column aliases
- All whitelisted SQL functions
- Package include CommonJS, ES Modules, UMD version and TypeScript declaration files.
- Support for
enum
type - Use
relations
for database joins - Support for function description (signature, example, etc.)
- Support for column description (type, info, etc.)
npm install @semiotic-labs/graph-autocomplete
import {AutoComplete, Suggestion, SuggestionType} from '@semiotic-labs/graph-autocomplete';
import {parse} from '@semiotic-labs/graph-tables';
const simple_schema = `
type SomeComplexTableErc20Name @entity {
"Some description about a string field"
id: ID!,
nullableField:Boolean,
booleanField:Boolean!,
bigIntField:BigInt!,
bytesField:Bytes!,
bigDecimalField:BigDecimal!,
intField:Int!,
int8Field:Int8!,
stringField:String!
}
`;
const layout = parse(simple_schema);
const autocomplete = new AutoComplete({logErrors: false, throwErrors: false});
autocomplete.updateLayout(layout);
const suggestions = autocomplete.suggest('SELECT some');
assert.equal(suggestions.some((suggestion) =>
suggestion.type === SuggestionType.TABLE
&& suggestion.value === "some_complex_table_erc_20_name"
),true);
The tool used to generate TypeScript code from an ANTLR 4 grammar is written in Java. To fully utilize the ANTLR 4 TypeScript target (including the ability to regenerate code from a grammar file after changes are made), a Java Runtime Environment (JRE) needs to be installed on the developer machine. The generated code itself uses several features new to TypeScript 2.0.
-Java Runtime Environment 1.6+ (1.8+ recommended)
See syntax
folder for updating both supported functions and SQL lexicon.After changes run
npm run lang-build