Giter Site home page Giter Site logo

Comments (13)

ardatan avatar ardatan commented on May 18, 2024 1

Available in 0.1.5!

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

We have an example for JSON Schema;
https://github.com/Urigo/graphql-mesh/tree/master/examples/json-schema-example

I tried an example and it worked.
Could you share the generated JSON Schema or share more details or a reproduction codesandbox something like this one?

https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/json-schema-example

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

@ardatan Thanks for the quick response!

Unfortunately, I don't think I can share the Schema, nor API because it is from work.
But I also tried to do something more simple using https://jsonplaceholder.typicode.com/
and was able to get it running. But, I fear the Schema is just too darn simple, eg. only one layer deep in terms of properties:

{
  "type": "object",
  "title": "Todo",
  "description": "Fake todo",
  "properties": {
      "userId": {
        "type": "integer"
      },
      "id": {
        "type": "integer"
      },
      "title": {
        "type": "string"
      },
      "completed": {
        "type": "boolean"
      }
  }
}

My original Schema has nested properties, for example:

{
  "type": "object",
  "title": "Article",
  "description": "some article",
  "properties": {
   ...,
   "mainImage": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "caption": {
          "type": "string"
        },
        "height": {
          "type": "integer"
        },
        "width": {
          "type": "integer"
        },
        "imageSizes": {
          "type": "object",
          "properties": {
            "thumbnail": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "height": {
                  "type": "integer"
                },
                "width": {
                  "type": "integer"
                },
                "links": {
                  "type": "array",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "href": {
                          "type": "string"
                        },
                        "rel": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "large": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "height": {
                  "type": "integer"
                },
                "width": {
                  "type": "integer"
                },
                "links": {
                  "type": "array",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "href": {
                          "type": "string"
                        },
                        "rel": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "fullSize": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "height": {
                  "type": "integer"
                },
                "width": {
                  "type": "integer"
                },
                "links": {
                  "type": "array",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "href": {
                          "type": "string"
                        },
                        "rel": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            },
            "medium": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "height": {
                  "type": "integer"
                },
                "width": {
                  "type": "integer"
                },
                "links": {
                  "type": "array",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "href": {
                          "type": "string"
                        },
                        "rel": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "attribution": {
          "type": "string"
        },
        "links": {
          "type": "array",
          "items": [
            {
              "type": "object",
              "properties": {
                "href": {
                  "type": "string"
                },
                "rel": {
                  "type": "string"
                }
              }
            }
          ]
        }
      }
    }
   }
...( more properties) ...

and some might be deeper.
Could this be the issue? Perhaps the nested properties don't need to be there?

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

I think this PR fixes the issue.
Could you try with the alpha version in this PR?
#263

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

Gave it a quick run... still doesn't seem to work.

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

@hamatoyogi I tried to reproduce it with the given details but it works well. Could you please help me to reproduce it?
https://codesandbox.io/s/twilight-bush-3uzrn?file=/.meshrc.yml

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

@ardatan Found what is breaking it...:

Basically, not having definitions for "type": "array" eg, not having the items defined.
Also, "type" : "null" seems to break things.

https://codesandbox.io/s/objective-black-ifnr6?file=/mesh-schema/json-schemas/article.json

(for some reason I can't restart the start process while working on the sandbox, so I couldn't break it - maybe I just don't know how 🤷- broke it local machine)

Got it working for me, but defining the shape of the arrays and changing the "null" to "string".

Maybe there is some stuff that could be addressed or at least documented.

Thanks for the help, and I hope this helps you guys!

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

image
You can restart it like that. But it is fine I restarted it and caught the probleem. And I pushed another fix for that situation. Now we handle both null and untyped arrays.

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

Awesome @ardatan !

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

@hamatoyogi Could you try and confirm it works on this alpha version?
0.1.5-alpha-cbc6867.0

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

@ardatan tried it out with the old JSON (empty array defs and "null" defs) and it doesn't work with 0.1.5-alpha-cbc6867.0

from graphql-mesh.

ardatan avatar ardatan commented on May 18, 2024

In here, I have both empty arrays and null defs, and it works with 0.1.5-alpha-cbc6867.0. Am I missing something?
https://codesandbox.io/s/damp-brook-l2s2v?file=/package.json

from graphql-mesh.

hamatoyogi avatar hamatoyogi commented on May 18, 2024

Might have been my bad... Tried again, and made sure all dependencies were aligned, files saved in VScode and all... Chalk it up to doing too many things at once 😅
Looks good @ardatan !

from graphql-mesh.

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.