Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enchancment: GraphQL Support #60

Closed
bagelbits opened this issue Feb 26, 2020 · 5 comments · Fixed by #139
Closed

Enchancment: GraphQL Support #60

bagelbits opened this issue Feb 26, 2020 · 5 comments · Fixed by #139
Assignees

Comments

@bagelbits
Copy link
Collaborator

Honestly, this would be kind of cool to have.

@bagelbits
Copy link
Collaborator Author

@theone85ca on Discord is spearheading this one.

@bagelbits bagelbits self-assigned this Oct 1, 2020
@bagelbits
Copy link
Collaborator Author

I've actually taken this own because we're on MongoDB Atlas now that supports this.

@bagelbits
Copy link
Collaborator Author

I've run into a blocker on this. Everything works except the spells table:

5e-database.5e-database.spells    <root>    InvalidType    unable to create type "SpellDamageDamage_at_character_level" because of no valid fields
5e-database.5e-database.spells    <root>    InvalidType    unable to create type "SpellDamageDamage_at_slot_level" because of no valid fields
5e-database.5e-database.spells    <root>    InvalidType    unable to create type "SpellHeal_at_slot_level" because of no valid fields

Here is the generated schema:

{
  "title": "spell",
  "properties": {
    "_id": {
      "bsonType": "objectId"
    },
    "area_of_effect": {
      "bsonType": "object",
      "properties": {
        "size": {
          "bsonType": "int"
        },
        "type": {
          "bsonType": "string"
        }
      }
    },
    "attack_type": {
      "bsonType": "string"
    },
    "casting_time": {
      "bsonType": "string"
    },
    "classes": {
      "bsonType": "array",
      "items": {
        "bsonType": "object",
        "properties": {
          "index": {
            "bsonType": "string"
          },
          "name": {
            "bsonType": "string"
          },
          "url": {
            "bsonType": "string"
          }
        }
      }
    },
    "components": {
      "bsonType": "array",
      "items": {
        "bsonType": "string"
      }
    },
    "concentration": {
      "bsonType": "bool"
    },
    "damage": {
      "bsonType": "object",
      "properties": {
        "damage_at_character_level": {
          "bsonType": "object",
          "properties": {
            "1": {
              "bsonType": "string"
            },
            "5": {
              "bsonType": "string"
            },
            "11": {
              "bsonType": "string"
            },
            "17": {
              "bsonType": "string"
            }
          }
        },
        "damage_at_slot_level": {
          "bsonType": "object",
          "properties": {
            "1": {
              "bsonType": "string"
            },
            "2": {
              "bsonType": "string"
            },
            "3": {
              "bsonType": "string"
            },
            "4": {
              "bsonType": "string"
            },
            "5": {
              "bsonType": "string"
            },
            "6": {
              "bsonType": "string"
            },
            "7": {
              "bsonType": "string"
            },
            "8": {
              "bsonType": "string"
            },
            "9": {
              "bsonType": "string"
            }
          }
        },
        "damage_type": {
          "bsonType": "object",
          "properties": {
            "index": {
              "bsonType": "string"
            },
            "name": {
              "bsonType": "string"
            },
            "url": {
              "bsonType": "string"
            }
          }
        }
      }
    },
    "dc": {
      "bsonType": "object",
      "properties": {
        "dc_success": {
          "bsonType": "string"
        },
        "dc_type": {
          "bsonType": "object",
          "properties": {
            "index": {
              "bsonType": "string"
            },
            "name": {
              "bsonType": "string"
            },
            "url": {
              "bsonType": "string"
            }
          }
        },
        "desc": {
          "bsonType": "string"
        }
      }
    },
    "desc": {
      "bsonType": "array",
      "items": {
        "bsonType": "string"
      }
    },
    "duration": {
      "bsonType": "string"
    },
    "heal_at_slot_level": {
      "bsonType": "object",
      "properties": {
        "1": {
          "bsonType": "string"
        },
        "2": {
          "bsonType": "string"
        },
        "3": {
          "bsonType": "string"
        },
        "4": {
          "bsonType": "string"
        },
        "5": {
          "bsonType": "string"
        },
        "6": {
          "bsonType": "string"
        },
        "7": {
          "bsonType": "string"
        },
        "8": {
          "bsonType": "string"
        },
        "9": {
          "bsonType": "string"
        }
      }
    },
    "higher_level": {
      "bsonType": "array",
      "items": {
        "bsonType": "string"
      }
    },
    "index": {
      "bsonType": "string"
    },
    "level": {
      "bsonType": "int"
    },
    "material": {
      "bsonType": "string"
    },
    "name": {
      "bsonType": "string"
    },
    "range": {
      "bsonType": "string"
    },
    "ritual": {
      "bsonType": "bool"
    },
    "school": {
      "bsonType": "object",
      "properties": {
        "index": {
          "bsonType": "string"
        },
        "name": {
          "bsonType": "string"
        },
        "url": {
          "bsonType": "string"
        }
      }
    },
    "subclasses": {
      "bsonType": "array",
      "items": {
        "bsonType": "object",
        "properties": {
          "index": {
            "bsonType": "string"
          },
          "name": {
            "bsonType": "string"
          },
          "url": {
            "bsonType": "string"
          }
        }
      }
    },
    "url": {
      "bsonType": "string"
    }
  }
}

@ecshreve
Copy link
Contributor

Just dropping this here so it doesn't get lost in discord (and because I'm forgetful)

Poked around with generating the graphql schema a bit tonight and i think i figured out the problem, in the graphql spec field names have to start with at least one uppercase or lowercase letter, and the field names in

Damage_at_character_level
Damage_at_slot_level
Heal_at_slot_level

are just integers. I did a find/replace for all of those and pre-pended them with an "a" just to check and was able to generate the graphql schema with no errors (just some warnings). http://spec.graphql.org/June2018/#sec-Names

@bagelbits bagelbits removed the blocked label Oct 30, 2020
@bagelbits
Copy link
Collaborator Author

Thanks @ecshreve!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants