-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add tags to post #1677
Comments
You also need to add a
|
@SachaG, Thanks. My intention was to add tags instead of categories, but together. I want to allow adding a tag to friends too. Currently it allows you to select an existing tag / category only |
Edit : there seems to be working example in the movie example, so I'll check this out. Though error messages are not quite clear in my case, see below. Hi, adding a schema with a '$' in the name throws an error when generating the GraphQL schema:
This prevents me from either adding objects or array in the schema whether I use The tested schema (mostly copied from the example in this issue): Tours.addField([
{
fieldName: 'vendingMachineIds',
fieldSchema: {
type: Array,
label: 'Id des distributeur',
control: "checkboxgroup",
editableBy:['admins', 'managers', 'runners'],
insertableBy:['admins', 'managers', 'runners'],
viewableBy:['admins', 'managers', 'runners'],
form: {
noselect: true,
type: "bootstrap-category",
order: 50,
options: formProps => []
,
},
resolveAs: {
fieldName: 'vendingMachine',
type: 'VendingMachine',
resolver: (tour, args, context) => {
if (tour.vendingMachineIds) return []
const vendingMachines = context.VendingMachines.loader.loadMany(tour.vendingMachineIds)
return Users.restrictViewableFields(context.currentUser, context.VendingMachines, vendingMachines)
},
addOriginalField: true
}
}
},
{
fieldName: 'vendingMachineIds.$',
fieldSchema: {
type: String,
optional: true,
editableBy:['admins'],
insertableBy:['admins'],
viewableBy:['admins'],
}
},
]) |
That's weird, because field whose names contains |
Hm thats weird, maybe that's related to the point, e.g there is some My guess is that you somehow hop over your check when the schema is an array, or there is an error in my schema which in turn have other things to fail. But it also happens with Object so I don't know... |
I think at this point the easiest thing is for you to just share your repo and specify some reproduction steps so I can try directly. It's hard to know the source of the issue otherwise. |
Yep I'll try to repro if I can't fix the schema |
Edit: see next comment instead The schema below does work, I used one field only instead of one field for the Array, as you do in the
So I guess that when That could explain why it is unhappy about the vendingMachineIds: {
type: Array,
optional: true,
resolveAs: {
fieldName: 'vendingMachines',
type: '[VendingMachine]',
resolver: (refill, args, context) => {
const machines = refill.vendingMachineIds && refill.vendingMachineIds.length
? context.VendingMachines.find(
{ _id: { '$in': refill.vendingMachineIds } },
{
fields: context.VendingMachines.getViewableFields(context.currentUser, context.VendingMachines)
}).fetch()
: [];
console.log(machines)
return machines
},
addOriginalField: true,
}
}, I am still investigating this right now |
God I think I finally got it! This explains those weird issues I encountered, everything seems to work well now I specified the fields. So the solution would be to add a small condition on the SmartForm (I can't tell exactly which underlying component is responsible for this yet) that scraps out invalid field names. Seems to be related to this function https://github.com/VulcanJS/Vulcan/blob/master/packages/vulcan-forms/lib/components/Form.jsx#L255 |
If you'd like me to look into this, could you provide the following?
|
Also if you'd like to open a more general discussion about how nested fields should be handled, feel free to open a new issue. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey, I'm trying to add tags to the post. I followed these instructions but I get an error.
my code:
the error:
Error: Type "null" not found in document.
The text was updated successfully, but these errors were encountered: