Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gql2flow

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gql2flow - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

util/fetcher.js

35

index.js
#!/usr/bin/env node
'use strict';
const isUrl = require('is-url');
const program = require('commander');

@@ -14,2 +16,5 @@

// Fetch utils
const fetchUtils = require('./util/fetcher');
program

@@ -42,10 +47,30 @@ .version('0.3.0')

)
.action((fileName, options) => {
let schema = fileIO.readFile(fileName);
.action((path, options) => {
const getSchema = new Promise((resolve, reject) => {
if (isUrl(path)) {
fetchUtils.fetchWithIntrospection(path, (err, schema) => {
if (err) {
reject(err);
} else if (!schema.data) {
reject(
new Error('Server replied with an invalid introspection schema')
);
} else {
resolve(schema);
}
});
} else {
resolve(fileIO.readFile(path));
}
});
let interfaces = interfaceUtils.generateTypes(schema, options);
getSchema
.then(schema => {
let interfaces = interfaceUtils.generateTypes(schema, options);
let module = moduleUtils.generateModule(options.moduleName, interfaces);
let module = moduleUtils.generateModule(options.moduleName, interfaces);
moduleUtils.writeModuleToFile(options.outputFile, module);
moduleUtils.writeModuleToFile(options.outputFile, module);
})
.catch(err => console.error(err.message));
})

@@ -52,0 +77,0 @@ .parse(process.argv);

8

package.json
{
"name": "gql2flow",
"version": "0.4.1",
"version": "0.4.2",
"description": "Convert a GraphQL Schema to a Flowtype definition",
"main": "index.js",
"dependencies": {
"commander": "^2.9.0"
"commander": "^2.9.0",
"is-url": "^1.2.2",
"node-fetch": "^1.6.3"
},

@@ -13,3 +15,3 @@ "devDependencies": {

"chai": "^3.5.0",
"graphql": "^0.7.2",
"graphql": "^0.9.6",
"mocha": "^2.4.5"

@@ -16,0 +18,0 @@ },

@@ -25,11 +25,10 @@ # GraphQL To Flow Types

#### With Default Options
#### Fetching from a server
```shell
gql2flow schema.json
gql2flow https://api.github.com/graphql
```
#### With Optional Options
#### From a json schema
```shell
gql2flow -i BadInterface,BadType,BadUnion -o schema.flow.js schema.json
gql2flow schema.json
```
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