Hotchocolate + Schema federation + GUID format crash - federation

We have a gateway API with stitching on and the schema is pulled from a redis cache where underlying APIs push their schema to.
When the APIs start, everything is fine - the underlying APIs push their schema to the cache and the gateway reads it.
If I update one the schema of an API, say by adding a string field or an int to try out if it would refresh it I get this error when I try to refresh the schema on banana cake pop
"HotChocolate.SchemaException: For more details look at the `Errors` property.
1. Operation is not valid due to the current state of the object. (HotChocolate.Types.UuidType)
at HotChocolate.Configuration.TypeInitializer.DiscoverTypes()
at HotChocolate.Configuration.TypeInitializer.Initialize(Func`1 schemaResolver, IReadOnlySchemaOptions options)
at HotChocolate.SchemaBuilder.Setup.InitializeTypes(SchemaBuilder builder, DescriptorContext context, IBindingLookup bindingLookup, IReadOnlyList`1 types, LazySchema lazySchema)
at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder)
at HotChocolate.SchemaBuilder.Create()
at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create()
at .... (cut for brevity)
After researching, we found that it happens when we add the instruction to format the output of the GUID by adding:
.AddType(new UuidType('D'))
To the setup of the Gateway API. If removed then everything appears to be fine.
Any idea if that can be resolved ? Really would like to keep the output format of the Guid to the one with dashes.
Thanks
Vincent

Related

How to check if exists when using CrudRepository#getOne()

I have a Document entity. To edit a document you must acquire a DocumentLock.
Request API to edit a document looks like below. edit=true allows to fetch the record from database with 'FOR UPDATE`.
GET /api/document/123?edit=true
In Back end side, we do like this (of course over simplified),
Document document = documentRepository.getOne(documentId) //<--- (1)
if(document == null){ //<--- (2) This is always false
//Throw exception
}
DocumentLock dl = DocumentLock.builder()
.lockedBy(user)
.lockedAt(NOW)
.document(document)
.build()
documentLockRepository.save(dl);
We are using getOne() because we do not need to fetch whole document from database, we are just creating a relation with DocumentLock object.
Question is, how to ensure the document actually exists? Because getOne() will always return the proxy and I do not see any obvious way to check if the record exists in databse.
Versions:
spring-data-jpa: 2.2.6.RELEASE
hibernate: 5.4.12
Update: removed additional questions.
Use findById or existsById. Yes they do access the database. That is the point of it, isn't it?
getOne is explicitly for use cases where you already know the entity exists and only need the id wrapped in something that looks like the entity.
If your repository returning value or its transactional management is confusing, you should check your repository codes and entity class design even session configurations that used for querying or even your Datastore design because everything looks fine in this code fragment

Get notified when TaggedValue of an element changes in Enterprise Architect

I am new in creating Addins for Enterprise Architect and I have this problem:
I have a diagram with elements which have TaggedValues. I want to get notified when the value of a TaggedValue changes and see the new value.
I saw that there is this event EA_OnElementTagEdit available but I can't seem to get it triggered. I also saw that the tagged value has to be of type AddinBroadcast but I can't seem to make it work. What am I missing?
I will put below a sample of my code:
//creating tagged value
EA.TaggedValue ob3 = (EA.TaggedValue)NewElement.TaggedValues.AddNew("Responsible", "val");
ob3.Value = EEPROMBlocks.ElementAt(index).Responsible;
ob3.SetAttribute("Type", "AddinBroadcast");
ob3.Update();
//event method
public override void EA_OnElementTagEdit(EA.Repository Repository, long ObjectID, ref string TagName, ref string TagValue, ref string TagNotes)
You are not missing anything. This is simply not possible. The only way around is the OnContext... where you temporarily store the status of one element and look if a tag has changed when the context changes. I would not recommend that since it involved a lot of superfluous DB accesses.
Send a feature request (if you are an optimistic guy). Alternatively you should think of ways to get around this somehow else.

Pagination feature in Pivotal GemFire

Is there any built-in API which provides a pagination feature in Pivotal GemFire, such as in the QueryService API or using Functions? We are currently using Pivotal GemFire 9.3.0 running in PCC.
TIA.
No yet. It is a planned feature for SD Lovelace/Moore release trains. See SGF-524 - Add support for PagingAndSortingRepositories. NOTE: sorting is already supported; paging is a WIP.
There is not. However there is a common pattern for this. Instead of directly querying the matching objects, write your query to return the keys of the matching objects. The client can then implement paging (e.g. page1 is key0-key99, page 2 is key 100-199, etc.). Use the "getAll" method with a list of keys to pull back one page at a time.
BTW, you can query the keys like this: "select key from /person.entries where value.ssn='222-22-2222'"

Adding a range on an enum field

I am trying to add a range (which I believe functions as a filter, right?) on an Enum field. This data source table is used in a Web Report.
This is what I do in the init method of the Web Report:
this.query().dataSourceTable(tablenum(SupplProduct)).addRange(fieldnum(SupplProduct, ShowOnReport)).value(QueryValue(NoYesCombo::Yes));
ShowOnReport is a field of type NoYesCombo Enum.
The Web Report crashes with this error:
Invalid range
I've managed to find quite a few examples on the web and this seems to be the proper way to do it so it supports all languages.
Any ideas ?
Could it be the properties of the field I'm trying to add a range on ?
Right underneath the line of code above, there is another similar line doing exactly the same, on another field:
//this is at the beginning of the init method...
AppointmentTable activeAppoint = element.args().record().data();
;
this.query().dataSourceTable(tablenum(AppointmentTable)).addRange(fieldnum(AppointmentTable, AppointmentId)).value(queryValue(activeAppoint.AppointmentId));
This range works fine.
Thanks.
Oh crap. The Enterprise Portal server and its Business Connector was still at version RTM while the AOS server it connects on is RU8. After I patched the EP server to RU8, this works.
Thanks.

Entity framework Conflicting changes detected. This may happen when trying to insert multiple entities with the same key

I have entity User with a couple of one-to-one and many-to-many relations and Identity primary key, and generic repository which created on each request.
I have an registration form with client and server validation and i decided to turn off client validation to test how server would behave in such case.
I turned off client validation to test the registration form and put some invalid values so i get back form saying that i have some errors, after i fixed that i got very interesting error
saying:
_context.SaveChanges(); //towing the error below:
Conflicting changes detected. This may happen when trying to insert multiple entities with the same key
It was strange for me because i detached the entity User but when i found this How to clean-up an Entity Framework object context?
so instead detaching only User entity i decided to try to clean object context completely running that code:
var objectStateEntries = this.objectContext
.ObjectStateManager
.GetObjectStateEntries(EntityState.Added);
foreach (var objectStateEntry in objectStateEntries)
{
if(objectStateEntry.Entity != null)
this.objectContext.Detach(objectStateEntry.Entity);
}
So after that all working well and i didn't get Conflicting changes detected error any more, but i am still wondering why such situation was taking place, may be some one may explain?
You may find your answer here:
context.ObjectStateManager.GetObjectStateEntries(System.Data.Entity.EntityState.Added| System.Data.Entity.EntityState.Unchanged);

Resources