Giter VIP home page Giter VIP logo

Comments (7)

kitze avatar kitze commented on September 2, 2024 3

I think this is a bug. It should be as @capaj is saying. If the property is there, it should be of type "string", but if it's not in the object, Flow should be fine with that object.

from gql2flow.

joarwilk avatar joarwilk commented on September 2, 2024

Hmm, I'm not sure here. I think having the value as null makes sense

// GraphQL Schema
User {
  id: ID!
  name: String
}

... + some user query

// GraphQL Query
{
  user(id: 123) {
    id
    name
  }
}

// result if name is not set
{
  "user": {
    "id": "123",
    "name": null
  }
}

// Matching flow definition
type User {
  id:  string,
  name: ?string
}

from gql2flow.

petrbela avatar petrbela commented on September 2, 2024

Well, technically, the right way to do this would be to have all properties optional (since it's up to the client to only request what they want), and those that can be null should be maybe types.

description?: ?string;
target?: ?any;

Or, in the case of user:

type User {
  id?: string,
  name?: ?string,
}

from gql2flow.

joarwilk avatar joarwilk commented on September 2, 2024

Yep, thats the proper solution @petrbela. Thanks, will implement.

Edit: although correct it might be a bit too verbose on the maybe types, will be somewhat frustrating to work with. I'll add all three variations and a cli flag to choose with.

from gql2flow.

kitze avatar kitze commented on September 2, 2024

@joarwilk I would love to see that, right now if i need to update 1 property i need to set all of the other ones to "null" just for Flow to work.

This is an awesome project and thanks for your great work!

from gql2flow.

gajus avatar gajus commented on September 2, 2024

Whats the reason for not using | null?

from gql2flow.

joarwilk avatar joarwilk commented on September 2, 2024

It now defaults to making no assumptions about the usage and then you can use it how you'd like with --null-keys and --null-values (v0.4.0).

from gql2flow.

Related Issues (20)

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.