Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 26 2017 20:07
    @remmeier banned @hibaymj
Atreyu79
@Atreyu79
Is there a way I can default Crnk-Compact to true in a resource repository? In my API I'm not persisting a particular resource, so it's never retrievable via GET... making self links misleading. I know we can intercept and force the header on a customer's behalf, but a more elegant solution is preferred if one exists. I'm unclear from the documentation what my options are here.
Rehab Reda
@rehab-reda0

Hi @remmeier any way to modify the related link here ?
"self": "http://example.com/articles/1/relationships/author"

"related": "http://example.com/articles/1/author"

Remo
@remmeier
it is possible to omit one or the other
@Atreyu79 no, not as of yet. was not deemed useful because it breaks discoverability in the broswer for developers/operators
should be more an optimization where needed
Rehab Reda
@rehab-reda0

I want for example to modify the url to be authors not author
"self": "http://example.com/articles/1/relationships/author"

"related": "http://example.com/articles/1/author"

@remmeier

Remo
@remmeier
@JsonProperty allows renaming
Rehab Reda
@rehab-reda0

I am having a problem we have a standarization that the url should be in kebab case
so If have account model which has a list of emailAddresses
I want the url to be like accounts/id/email-addresses

but the relationship in the response body should be in camelCase

I solved the first part by modifying the url in spring boot filter so if the user request accounts/id/email-addresses it is then converted to accounts/id/emailAddresses
but the links in the response how can i modify relationship links ?
Matt12432
@Matt12432
Hi all, I'm trying to get a url like this to work: /authors/{authorId}/books/{id} to return a specific book out of the list of books that belong to the author however I get an error saying "cannot add further url fragements after field". Should the above url be possible? I've also tried using a filter like /authors/{authorId}/books?filter["id"]={bookId} however that returns an error saying that the property id doesn't exist even though the call to beanInformationBase.findFieldByJsonName() appears to have an id property in the hashmap. Appreciate any help on this.
Rehab Reda
@rehab-reda0
@Matt12432 yes it is possible by applying the nested resources check here https://www.crnk.io/releases/stable/documentation/#_nested_resources
Matt12432
@Matt12432
Thanks @rehab-reda0 that has worked
Atreyu79
@Atreyu79
@remmeier Thanks
Remo
@remmeier
@rehab-reda0 having a
a Name and NamingStrategy would be nice sometime. the former hilding a java, json and path name. this used in the ResourceField class.
Rehab Reda
@rehab-reda0
Thank you @remmeier so how can I add this customized url builder class ?
from the boot configuration ?
I can't find a seturlbuilder function or from the setupmodule I can't find context.seturlbuilder
Remo
@remmeier
lmaxbe it has to be added, customizing it has not come up so far
Rehab Reda
@rehab-reda0
@remmeier so I will use just implement a class from the url builder and make it as a bean ?
fkohl04
@fkohl04
@DeafLight Quite a while ago you said, that you are trying to use crnk with Ktor. Have you been successful with this?
Justin Gottschalk
@justindevs
I am using the client to communicate communicate with a spring boot crnk api using the in memory storage. One of the keys I am filtering on can contains string with commas and that is getting split into a set in the filter and will not match on the whole string. Is there a way around crnk treating the commas as a list/set?
2 replies
Remo
@remmeier
@rehab-reda0 somewhere in the setup/CrnkBoot it should be possible to set a custom UrlBuilder.
Matt12432
@Matt12432
Hi sorry I have another query related to previous one, I'm not sure how the url for filtering on nested resources should be structured. For instance if I want to filter books for an author where the name is bookName. I've tried /authors/{authorId}/books?filter[book.name]=bookName which errors saying that there is no property book.name on the book object (its just called name). I've also tried /authors/{authorId}/books?filter[name]=bookName and /authors/{authorId}/books?filter[book][name]=bookName however these then go through authors findAll method instead of the books relationship repo. Once again I appreciate any help with this thanks.
Remo
@remmeier
books.name, there are some more advanced options in the docs, like filtering relationships only, not the requested roots
Matt12432
@Matt12432
Sorry yes the first scenario above should have said [books.name]. I'm not exactly sure where in the documentation I should be looking. Ideally in the above scenario it would still be possible to run a query like this /authors?filter[name]=authorName but filtering both at the same time wouldn't be required
Remo
@remmeier
Rehab Reda
@rehab-reda0

@rehab-reda0 somewhere in the setup/CrnkBoot it should be possible to set a custom UrlBuilder.

Can u please give me an example? I can't figure it out
@remmeier

Remo
@remmeier
I dont think it is currently possible. One would have to check the occurrences of new UrlBuilder(...) and maybe make it customizable.
Roy
@depzor
Hi all,
I have 1 resource type "users" which could reside in two repositories. Based on some parameter it should be retrieved from the current database or from an external system.
Currently I have one database table named "subscriptions" which has a ManyToOne relation with the UserEntity. In order to support an external user repository I am thinking about
adding a new field in the database table "subscriptions" like "externalUserId". Are there any best practices to support two dynamic "user" repositories with relationships to my "subscriptions" resource?
Roy
@depzor
Is there a maven plugin available for crnk-gen? https://github.com/crnk-project/crnk-framework/tree/master/crnk-gen
Remo
@remmeier
just gradle as of yet. but the gradle plugin is just a thing wrapper around a plain Java app. So a Maven plugin or Java main is possible with a few lines.
Maybe I wound consider encoding the location in the resource id? which must not necessarily be equal to the database id
Carla McNearny
@cmcnearny
Hello. I am setting the Crnk-Compact header to true and the links object is correctly omitted for a single relationship.
However, for one-to-many relationships, an empty relationship and links is returned when it is empty, and an empty links: {} is returned when relationship is not empty.
This is not the behavior I expect, according to the documentation: Further relationships without data are completely omitted.
Remo
@remmeier
empty relationship like 0 entries or not loaded?
Carla McNearny
@cmcnearny
A resource that does not yet have any notes, eg:
"notes": { "data": [], "links": {} }
Remo
@remmeier
the data part is correct. a loaded but empty array should not be removed.
Steve Brush
@brushs
I am trying to add a computedAttribute in QueryDSL and have the returned via the API. I'm calling the factory.registerComputedAttribute() method as in one of the test cases I found (only example?) and nothing blows up -- however the field is not returned by the API and any attempt to reference it fail (fields, include) and I'm not sure on the trick to have that field actually returned. All I get currently are 400 - Unknown Parameter - Failed to resolve path to field errors. Any suggestions what may be missing, or the correct way to access the field?
Remo
@remmeier
maybe worth opening a bug. Personally I mostly moved to DB Views rather than direct table access for this kind of use cases.
Roy
@depzor
Hi all, I checked out the spring-boot-microservice-example and I am a bit stuck with the filtering. I am trying to filter all tasks by a project name like for instance:
/task?filter[project][name][eq]=Great%20Project
Shouldn't that be possible? Or perhaps I am missing something here
Remo
@remmeier
there are two types of filters, filter the root or filter on relationships. your example is the later. filter[project.name] is what you are looking for
Roy
@depzor
Did that as well, but InMemoryEvaluator does not seems to handle that
Roy
@depzor
I guess it isnt backed by a ResourceRegistry (at least in the demo project)
Remo
@remmeier
it can filter what is in memory. it does not resolve @JsonApiRelationId as of yet
Roy
@depzor
Would it be possible to support multiple repositories for the same resourceType? Based on a dynamic parameter it should use either a JpaRepository or something else for a specific request.
Roy
@depzor
nvm got something up and running already :)
Steve Brush
@brushs
is there any trick available to have entities to pass child entity collections as attributes rather than relationships on creation? this could possibly allow for transactional creation of children without the need for a Dto.
Remo
@remmeier
a resource dedicated to that use case or the operator module to bulk insert all changes
wulfcolin
@wulfcolin
Hi @remmeier ,
As jcenter is not allowing the publishing of new packages, are you going to publish newer versions on maven central ?
Remo
@remmeier
that is the plan. And rework the pipelipe with github actions, away from travis.
Roy
@depzor
When you use the JpaModule and try to filter on a relationship Id JPA performs an inner join query behind the scenes.
This makes it impossible to filter on a 'null' value relationship. Let say you want to retrieve all records that do not have jpa association (null) with entity X.
Something like this: "select id, name, project_id from tasks where project_id is null"