Data model relationship generation
Describe the bug
A Type containing multiple fields that contain relationships on the Data Model create a single expected Input Type in all the fields of said Type, as below:
To Reproduce Steps to reproduce the behavior:
- Given the following data model:
type UserContact {
email: String
telephone: String
}
type UserSession {
session_start_timestamp: Float
session_end_timestamp: Float
}
type Article @GQLifyModel(dataSource: "firestore", key: "articles") {
id: ID! @unique @autoGen
title: String
content: String
}
type Video @GQLifyModel(dataSource: "firestore", key: "videos") {
id: ID! @unique @autoGen
title: String
url: String
}
type User @GQLifyModel(dataSource: "firestore", key: "users") {
id: ID! @unique @autoGen
user_contact: UserContact!
user_sessions: [UserSession!]!
bookmarked_articles: [Article!]! @relation(name: "UserOnArticles")
bookmarked_videos: [Video!]! @relation(name: "UserOnVideos")
}
- Open the schema generated by GQLify
- Observe that the
inputFieldsof bothbookmarked_articlesandbookmarked_videosrefer toUserCreateManyInput
{
"name": "bookmarked_articles",
"description": "",
"type": {
"kind": "INPUT_OBJECT",
"name": "UserCreateManyInput",
"ofType": null
},
"defaultValue": null
}
{
"name": "bookmarked_videos",
"description": "",
"type": {
"kind": "INPUT_OBJECT",
"name": "UserCreateManyInput",
"ofType": null
},
"defaultValue": null
}
- Look at
UserCreateManyInputand observe theinputFieldsofcreateandconnect
{
"kind": "INPUT_OBJECT",
"name": "UserCreateManyInput",
"description": "",
"fields": null,
"inputFields": [
{
"name": "create",
"description": "",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "VideoCreateInput",
"ofType": null
}
},
"defaultValue": null
},
{
"name": "connect",
"description": "",
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "VideoWhereUniqueInput",
"ofType": null
}
},
"defaultValue": null
}
],
"interfaces": null,
"enumValues": null,
"possibleTypes": null
}
- They refer, respectively, to
VideoCreateInputandVideoWhereUniqueInput.
Expected behavior
Each relationship should create a unique inputField value, e.g. UserCreateManyArticlesInput and UserCreateManyVideosInput, where each refer to the correct input shape.
Desktop (please complete the following information):
- OS: OSX
- Version 10.14.2
Additional context
No matter how many field relationships you have above 1, the Input Object referred to by UserCreateManyInput is always the last field.
In the example above, if I were to add a third relation field e.g. bookmarked_xs, the UserCreateManyInput would then start referring to XCreateInput and XWhereUniqueInput.