![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
sk-query-builder
Advanced tools
No need for multiple functions, commands, or es5 compatible compiling. Just create a single Query with an options object and get a GraphQL ready query string in return.
Forked from https://github.com/codemeasandwich/graphql-query-builder - a simple ES6 graphql query builder
info:
npm install sk-query-builder
Query is available out of the box on the Window object, but can also be required to prevent namespace interference.
var Query = require('sk-query-builder');
Query can be called with a single arguement of either a single query object or an array of query objects and will return a GraphQL formatted string to be attached to query.
var query = Query( query_obj[, options ] );
Single query object or an array of multiple queries to turn into a GQL query string.
Key Value | Argument | Description |
---|---|---|
func: | String | the name of the query function |
alias: | String | alias value that result will be returned under |
filters: | Object | An object mapping attribute to values |
value: | String or Object | Attribute name or nested query you want returned. Can be an array of multiple values with the values: key |
values: | Array | An Array of value items ( String or Obj ) to return multiple values |
var sumQuery = Query({
func: "sum",
alias: "total_sum",
filters: { from: 0, to: 1501234567890 },
value: "count"
});
"{total_sum: sum(from: 0,to: 1501234567890){count}}"
Key Value | Argument | Description |
---|---|---|
prefix | String | prefix string before query obj ( i.e. "mutation" ) |
var prefixQuery = Query({
func: 'update',
filters: { id: 1, value: 3 },
value: [ "id", "value" ]
}, { prefix: 'mutation' );
console.log( prefixQuery );
// "mutation{update(id:1,value:3){id,value}}"
Add Enum values inside query objects buy either the Enum() function with a string to represent the final value or by simply using any string starting with "e$"
Enum( 'VALUE' ) == 'e$VALUE'
Argument (one) | Description |
---|---|
String | the name of the query function |
var eventQuery = Query({
alias: 'event_123',
func: 'event',
filters: {
frequency: Enum( 'DAILY' ), // can also be "e$DAILY"
value: Enum( 'CLICKS' )
},
values: [ 'timestamp', 'value' ]
});
console.log( eventQuery );
// "{event_123:event(frequency:DAILY,value:CLICKS){timestamp,value}}"
var FetchLeeAndSam = Query({
alias: 'FetchLeeAndSam',
func: 'users',
values: [
{
alias: 'lee',
func: 'user',
filters: { id: '1' },
values: ['name', 'id' ]
},
{
alias: 'sam',
func: 'user',
filters: { id: '2' },
values: ['name', 'id' ]
}
]
});
console.log( FetchLeeAndSam );
//"{FetchLeeAndSam:users{lee:user(id:"1"){name,id},sam:user(id:"2"){name,id}}}"
var reusable = function( model, year ) {
return {
alias: model,
func: 'vehicle',
filters: { year: year },
values: [
"num_produced",
"horsepower"
]
};
};
var CarCatalog = Query([
reusable( 'Mustang', '1964' ),
reusable( 'Camero', '1988' )
]);
console.log( CarCatalog );
//"{Mustang:vehicle(year:"1964"){num_produced,horsepower} Camero:vehicle(year:"1988"){num_produced,horsepower}}"
node example/simple.js
FAQs
An even simpler es5 friendly GraphQL query builder
The npm package sk-query-builder receives a total of 2 weekly downloads. As such, sk-query-builder popularity was classified as not popular.
We found that sk-query-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.