Giter VIP home page Giter VIP logo

graphqlizejs's Issues

[Feature] add support to subscriptions

Taking advantage of Sequelizejs hooks to generate 'subscriptions' data type and resolvers from models that have enabled the options:

gqSubscriptionCreate: true,
gqSubscriptionUpdate: true,
gqSubscriptionDelete: true

[schema] Generate object schema structure, before generate the schema.

Before the start generate the schema, build an object structure, test it and generate the schema from this object instead of look direct over sequelize models.

{
   "scalars": [],
    "inputs": {},
    "types": {
        "Query": [],
        "Mutation": [],
        "Subscription": [],
        "category": [
            {
                "name": "id",
                "type": {
                    "name": "ID",
                    "allowNull": false,
                    "collection": false
                },
                "args": [
                    {
                        "name": "_where",
                        "type": {
                            "name": "_inputWhereId"
                        }
                    }
                ]
            }
        ]
    }

[Feature] Add JSON support to the list of sequelize's supported types.

Hi there,

First and foremost, thank you for your work. I really appreciate it.

TL;DR:

Add support to the JSON DataType either by a) adding it to the Object of types mapSequelizeToGraphql in types.js, or b) removing the absolute switch you pass to mapTypes() in schemas.js, in the body of generateInputOperators().

A deeper explanation

In some of my models I need to use JSON fields. According to the sequelize docs the JSON data type is supported.

I tried to check if my models would work with your library, so I took the code from your example folder and tried it along with my models; then got this error:

SyntaxError: Syntax Error: Expected Name, found ":". (99:3)
   97 | input _inputOperator {
   98 |             eq:
>  99 | ne:
      |   ^
  100 | gte:
  101 | gt:
  102 | lte:
    at e (/home/chirvo/sequelize2/node_modules/prettier/parser-graphql.js:1:319)

I know that's a sequelize error, so I started tracing the bug. Long story short, it took me to schemas.js, function generateInputOperators(). In it, you import mapTypes() from types.js and pass it a switch for it to return exactly a value of a existing key in an object constant mapSequelizeToGraphql. declared in the same types.js. Because of this, when you pass JSON as a datatype, the returned value is an empty string.

Now the possible solutions I propose are quite simplistic, and since I haven't dig deep enough in your code they may prove not viable, but here they are anyway: Either add the JSON datatype to the mapSequelizeToGraphql, or remove the absolute switch from the mapTypes call in generateInputOperators. I saw that the only place you call it using the switch is right there; other calls to the same function are not using the switch. Probably the later one may introduce bugs, or break any edge cases you foresaw that I didn't.

If you want me to do a PR with any of these proposed solution let me know.

Thanks!

EDIT: Formatting.

Datetime types is returning wrong value

Datetime values is returning a non sense integer that even it's not a timestamp.

v0.3.5 version fix it adding de scalar type date/datetime/time where will convert the datetime values to right scalar type.

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.