-
Notifications
You must be signed in to change notification settings - Fork 35
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
extras in relationShipMappings not supported ? #51
Comments
It won't be there if it's not in your schema. |
@timhuff what exactly do you mean? I thought the schema gets generated based on the models: const graphQlSchema = graphQlBuilder()
.model(User)
.model(Account)
.build(); Is it supposed to work and where in my schema should I put the extra columns that are on the link table? Will the generated GraphQL filters work for the extra columns too? Would you be so kind to put a tiny example here? Thank you |
Yea, sorry for being so terse there. I just meant to toss out the answer real quick and didn't take the time I should've. As far as this library is concerned, if a property is not included in your json schema, it's not going to be available via the generated GraphQL API. The schema is how this library generates the API at all - so I was just pointing out "even if it did support extras, they wouldn't show up because its not part of your schema". So then we get to the topic of I think you could use the pull request I just put in earlier today (didn't exist when I left my last comment) to get around this but I'm not positive. Its intention was to support virtual properties without the need to turn off select filtering... but I see no reason it wouldn't work for this purpose as well. If you take a look at the file at this link, you'll see an example of how to use that pull request. The property utilizing my pull request is So, for your purpose, you'd just add the following to your model and then utilize my pull request static get virtualJsonSchemaProperties() {
return {
somethingExtra: { type: <data type of prop> }
}
} If this ends up working out for you, I'd appreciate it if you'd come back here and let me know - this is an interesting use case for it. |
Oh, and as for the "will generated filters work" question... I'm not sure but I have the feeling they might. |
Great, thanks @timhuff I will give it a try and report here later. |
@BerndWessels This end up working out for you? |
@timhuff Sorry, I am just back to work now and will try it now. Let you know soon. |
@BerndWessels Just letting you know that we reverted the merge I referenced here. Virtual attributes are properly supported now, though, so you might be able to add your extra to the |
Hi this documention says there can be extra columns in relationship tables - and they get mapped into the related models.
But its seems I can't use them in GraphQL Query? Is this possible, or can you please add it?
I also want to be able to provide a parameter to filter on that extra column.
graphql(graphQlSchema, `{ users { id name accounts { id name somethingExtra } }
The text was updated successfully, but these errors were encountered: