Closed ahoyahoy closed 2 years ago
You can provide custom serialization behavior by overriding the default serializer class or specifying additional serializer settings. You can read more about it in the docs.
In your case, you can add the serializerSettingsFor option to the remote source, which will let you pluralize/singularize model names. Here is an example from the docs:
const source = new JSONAPISource({
schema,
serializerSettingsFor: buildSerializerSettingsFor({
sharedSettings: {
// Optional: Custom `pluralize` / `singularize` inflectors that know about
// your app's unique data.
inflectors: {
pluralize: buildInflector(
{ person: 'people' }, // custom mappings
(input) => `${input}s` // naive pluralizer, specified as a fallback
),
singularize: buildInflector(
{ people: 'person' }, // custom mappings
(arg) => arg.substring(0, arg.length - 1) // naive singularizer, specified as a fallback
)
}
},
...
Hope it helps
Please add an example of changing json:api url serializers. In particular, I want to change the model name in the url where the letter 's' is appended to the end. 🙏