Giter VIP home page Giter VIP logo

gql2flow's People

Contributors

danielbuechele avatar gajus avatar insidewhy avatar joarwilk avatar limpbrains avatar meta-dreamer avatar orta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gql2flow's Issues

is this repo still maintained?

It has been quite a while since the last release, there are still bugs in the latest published 0.4.5

As far as I know this is still the best GraphQL -> FlowType tool out there. Would you like help maintaining this project?

Generate correct types for queries and mutations

Hi! Will be nice to see such updates! What do you think?

Schema example

type Thing {
  name: String!
}

input ThingsFilter {
  nameStartFrom: String
}

type Query {
  things(count: Number!, filter: ThingsFilter): [Thing!]
}

input ChangeProjectTitleInput {
  name: !String
}
type Thing {
  thing: Thing!
}

type Mutation {
  addThing(input: AddThingInput!): AddThingPayload
}

Current output:

...
declare type Query = {
  things: ?Array<Thing>;
}

declare type AddThingInput = {
  name: string;
}

declare type AddThingPayload = {
  thing: Thing;
}

declare type Mutation = {
  addThing: ?AddThingPayload;
}

Expected output:

...
declare type ViewerSubjectsArgs = {
  count: number;
  filter: ?ThingsFilter;
}
declare type Query = {
  things<ViewerSubjectsArgs>(): ?Array<Thing> | Promise<?Array<Thing>>;
}

declare type AddThingInput = {
  name: string;
}

declare type MutationAddThingArgs = {
  input: AddThingInput;
}

declare type AddThingPayload = {
  thing: Thing;
}

declare type Mutation = {
  addThing<MutationAddThingArgs>(): ?AddThingPayload | Promise<?AddThingPayload>;
}

gql2ts

@joarwilk

Hey...

this repo looks pretty familiar. just wanted to let you know that the v1 of gql2ts supports flow output (and would appreciate any help to improve that) and fixes a bunch of issues with the v0.x versions (which this seems to be based off of)

p.s. in the future, forking, attributing, or maintaining the history would really be nice. i understand that our license is MIT and I have no leg to stand on, but some attribution would go a long way.

Invalid flow schema

Hi, the scheme generated with gql2flow looks like this:

export type Query = {
  __typename: string;
  /** Fetches an object given its ID */
  node?: Node;
  me?: User;
  viewer?: Viewer;
}

but it should be

export type Query = {
  __typename: string;
  /** Fetches an object given its ID */
  node: ?Node;
  me: ?User;
  viewer: ?Viewer;
}

Am I right? Because the key is always defined, but it can return null

fields with default values should not be marked as optional

Given this GraphQL type:

input PaginationInput {
  first: Int = 20
  last: Int
}

The following FlowType is generated:

declare type PaginationInput = {
  first?: number;
  last?: number;
}

But it should look like this:

declare type PaginationInput = {
  first: number;
  last?: number;
}

Make output deterministic (the same each time it is run)

First off, thanks for a great library! This is very useful.

Second, right now, I get a diff whenever I run gql2flow http://localhost:4000/api -o src/tools/types/schema/index.js.flow --null-keys even though the GraphQL schema hasn't changed; this diff is just the gql2flow output shuffling around in a different order:
screen shot 2017-09-15 at 10 55 30 am
screen shot 2017-09-15 at 10 54 55 am

It would be great if the output wouldn't change if the input didn't change so that there is no diff when there are no changes.

Whats the reason for `__typename`?

I'd like to use the generated Flow types in my resolvers. Resolvers do not return __typename field; it is an internal field. Whats the reason for including it in the output?

make it accept a url of graphQL endpoint as well as a file

now I have to make the IntrospectionQuery myself, save the file as json and then run gql2flow command.

It would be really convenient if I could just do something like:

gql2flow https://graphql-explorer.githubapp.com/graphql/proxy

Fix the tests

It is really hard to contribute to a repository when the tests are broken. :-(

whitelist types additional to ignore types

Hi,

I'm using a graph.cool backend and there I have tons of types I would like to ignore. In my case it makes more sense to choose which types should be generated, not ignored. Any thought?

Feature request: upgrade to latest graphql standards

Would be great if this supported schema.graphql file types as well so it could be used with graphql-cli: https://github.com/graphcool/graphql-cli.

"The format specified by graphql-config will be the foundation for all schema-aware GraphQL tools...If you're the author or maintainer of a GraphQL library or another related tool, we encourage you to adopt the graphql-config standard. Please link to this GitHub issue to track the progress.
As mentioned before, the graphql-cli can be extended with plugins to support custom use cases. Feel free to start building your own plugins to support your GraphQL development workflow or tackle further use cases."

https://www.graph.cool/blog/2017-08-01-graphql-config-and-cli-aeghee3di9/

Optional fields on Input types are only set as maybe and not optional

Lets say there's an input type:

input UpdateProfileInput {
  id: ID!
  name: string
  email: string
}

The generated type is:

declare type UpdateProfileInput = {
  id: string;
  name: ?string;
  email: ?string;
}

Which requires that both name and email be provided. This input object would falsely give an error:

const input = {
  id: '123',
  name: 'John Doe',
}

To get rid of the error right now you have to do:

const input = {
  id: '123',
  name: 'John Doe',
  email: undefined
}

The generated type should be:

declare type UpdateProfileInput = {
  id: string;
  name?: ?string;
  email?: ?string;
}

How to use these annotations

Hi, @joarwilk
Thanks for this lib!

I have a question.
How do you use file generated by this script ? Do you add it somewhere to .flowconfig so types would be global ?
I'm thinking to add export before every type keyword, so I could import them anywhere. May be this should be default behaviour?

bug on GraphQLEnumType

I have this GraphQLEnumType

export default new GraphQLEnumType({
  name: 'BirthdayFilter',
  values: {
    day: {
      value: 'day',
      description: 'people doing birthday today',
    },
    week: {
      value: 'week',
      description: 'people doing birthday in this week',
    },
    month: {
      value: 'month',
      description: 'people doing birthday in this month',
    },
  },
});

and it is generating this:

null
export type BirthdayFilter = "day" | "week" | "month";

Cannot find module 'graphql/utilities'

I am not sure why it's happening. I am running the command gql2flow http://localhost:3000/graphql inside my project folder where graphql module installed. It should be able to find it yet fails...

Error: Cannot find module 'graphql/utilities'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\users\DarkMaster\AppData\Roaming\nvm\v8.1.4\node_modules\gql2flow\util\fetcher.js:7:5)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

I am on Windows 10 x64, Node 8.1.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.