New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-query-factory

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-query-factory

![CI Build Status Bar](https://travis-ci.org/alechp/graphql-query-factory.svg?branch=flow)

  • 1.0.12
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

GraphQL Query Batcher

CI Build Status Bar

Status

You can use QueryBuilder today. QueryBuilder takes an array of variable objects and injects them into your GraphQL query.

Roadmap

  • QueryFactory - Combines Builder & Batcher
  • QueryBuilder - Builds individual query strings based on the number of variable combinations you have.
  • QueryBatcher - Executes the entire array of GraphQL Query Strings.
  • Ava Tests
  • Flow Integration
  • CI status bar

Getting Started

Installation
npm install graphql-query-factory -S
Sample Use

QueryFactory

Not available yet

QueryBuilder - Sample Project

const { builder } = require('graphql-query-factory');
const log = console.log;

const sampleMutation = `mutation addMarkup($markup:String!, $raw: String!) {
    createContent(
      markup: $markup
      raw: $raw
    ) {
      markup
      raw
    }
  }`;

  const queryVariablesArray = [
    {
      "markup": "markup1",
      "raw": "raw1"
    },
    {
      "markup": "markup2",
      "raw": "raw2"
    },
    {
      "markup": "markup3",
      "raw": "raw3"
    }
  ];

  let queries = builder(sampleMutation, queryVariablesArray)
                .then( data =>
                    data.map(d => log(d))
                )
                .catch(err => log(`QueryBuilder failed. Error: ${err}`));

QueryBuilder Output:

mutation addMarkup($markup:String!, $raw: String!) {
    createContent(
      markup: markup1
      raw: raw1
    ) {
      markup
      raw
    }
  }
mutation addMarkup($markup:String!, $raw: String!) {
    createContent(
      markup: markup2
      raw: raw2
    ) {
      markup
      raw
    }
  }
mutation addMarkup($markup:String!, $raw: String!) {
    createContent(
      markup: markup3
      raw: raw3
    ) {
      markup
      raw
    }
  }

QueryBatcher

Not available yet

Todo

The TODO Sections represents smaller tasks that fit within the context of the Roadmap.

Builder
  • Ensure that output is formatted as an array
Batcher
  • tests
    • execute single query
    • execute all queries
    • [ ]
Flow Types
  • Add Flow types to QueryBuilder
  • Add Flow types to QueryBatcher
  • Fix remaining Flow type errors (appended at README below)
Environment Variables
  • Replace GCOOL variables with generic names
  • Update references in Travis build system (via travis website)
  • Add information on readme about configuring env variables
Examples
  • Add factory-queries.js sample
    • Add documentation that demonstrates this usage
    • Add Ava test
  • Fix batcher-queries.js
    • Add documentation that demonstrates this usage
    • Add Ava test
  • Add React (CRA) example
  • Add simple node (CLI) example
Finishing Touches
  • Create walkthrough video on usage
  • Generate static site that explains
  • Post to #general in Graph.cool slack channel
  • Add repository field to Package
  • Add apollo-codegen apollo tutorial
  • Add contribution section below
  • Remove Flow Errors below
  • Move all examples to one directory

Current Flow Errors to Cleanup:
src/batcher.js:15
 15:   constructor(queries, concurrent) {
                   ^^^^^^^ parameter `queries`. Missing annotation

src/batcher.js:15
 15:   constructor(queries, concurrent) {
                            ^^^^^^^^^^ parameter `concurrent`. Missing annotation

src/builder.js:47
 47:   injectQueryArguments(queryTemplate: string, queryParams: Array<string>, queryVariables: mixed): Array<string>{
                                                                                                       ^^^^^^^^^^^^^ array type. This type is incompatible with an implicitly-returned undefined.

src/builder.js:52
 52:      for(let varObj of queryVariables){
          ^ property `@@iterator` of $Iterable. Property not found in
 52:      for(let varObj of queryVariables){
                            ^^^^^^^^^^^^^^ mixed

src/builder.js:60
 60:            return (matchIncrementor == 2) ? value : match;
                                                 ^^^^^ mixed. This type is incompatible with
291:     replace(searchValue: string | RegExp, replaceValue: string | (substring: string, ...args: Array<any>) => string): string;
                                                                                                                  ^^^^^^ string. See lib: /private/tmp/flow/flowlib_8d4b9e8/core.js:291

src/builder.js:81
 81:       let qWithArguments: Array<string> = await this.injectQueryArguments(q, qParams, qVars);
                                                                                  ^^^^^^^ null. This type is incompatible with the expected param type of
 47:   injectQueryArguments(queryTemplate: string, queryParams: Array<string>, queryVariables: mixed): Array<string>{
                                                                ^^^^^^^^^^^^^ array type

src/builder.js:81
 81:       let qWithArguments: Array<string> = await this.injectQueryArguments(q, qParams, qVars);
                                                                                  ^^^^^^^ undefined. This type is incompatible with the expected param type of
 47:   injectQueryArguments(queryTemplate: string, queryParams: Array<string>, queryVariables: mixed): Array<string>{
                                                                ^^^^^^^^^^^^^ array type

Keywords

FAQs

Package last updated on 14 Sep 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc