Skip to content

invalid graphql schema gen #127

@danstarns

Description

@danstarns

Hey all.

Given I have this schema:

Image

Arrows will generate the following graphql schema:

type Customer {
  name: John Smith
  orderPlacedBy: Order @relationship(type: "PLACED_BY", direction: IN)
}

type Order {
  id: ORD-001
  placedByCustomer: Customer @relationship(type: "PLACED_BY", direction: OUT)
  productBelongsToOrder: Product @relationship(type: "BELONGS_TO_ORDER", direction: IN)
}

type Product {
  name: Wireless Earbuds
  price: 79.99
  quantity: 1
  belongsToOrderOrder: Order @relationship(type: "BELONGS_TO_ORDER", direction: OUT)
}

The problem is, that the field types are directly passing thru the value, and not assuming the type, resulting in a parser error if you were to run the schema through the graphql parser.

To fix this, we should have some inference to the right side of the colon so we generate valid graphql syntax.

type Customer {
-  name: John Smith
+ name: String
  orderPlacedBy: Order @relationship(type: "PLACED_BY", direction: IN)
}

type Order {
-  id: ORD-001
+ id: String
  placedByCustomer: Customer @relationship(type: "PLACED_BY", direction: OUT)
  productBelongsToOrder: Product @relationship(type: "BELONGS_TO_ORDER", direction: IN)
}

type Product {
-  name: Wireless Earbuds
+ name: String
-  price: 79.99
+  price: Int
-  quantity: 1
+ quantity: Int
  belongsToOrderOrder: Order @relationship(type: "BELONGS_TO_ORDER", direction: OUT)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions