I have apollo type like this one:
Client {
firstName
lastName
}
Is there any option to create a separated field called fullName or build some helper which will be a part of apollo, and includes values of those 2 fields?
It can be done by extending schema locally: https://www.apollographql.com/docs/tutorial/local-state/#define-a-client-side-schema
Related
I added a few custom string fields using NameValuePair in the Lead form (CR301000). Using the an Action, I create a contact from the lead. I added the same custom fields to my Contact form (CR302000). How can I get the custom values from my lead to my new contact? I tried using the following:
[PXFormula(typeof(Selector<CRLead.contactID, ContactExtNV.usrCROnline>))]
I'm going to have the same issue when I create an account from the lead. Is there a better way to do this instead of using PXFormula?
The Selector parameter for the PXFormula attribute looks like this:
Selector –> Selector<KeyField, ForeignOperand>
KeyField-> The key field to which the PXSelector attribute should be attached.
ForeignOperand-> The expression that is calculated for the data record currently referenced by PXSelector.
That is, in your case it turns out like this:
[PXFormula(typeof(Selector<Contact.contactID, CRLeadExt.usrCROnline>))]
public string UsrCROnline { get; set; }
Adding namespace in the source code using Customization Project Editor
I have foo an instance of the ember-data model thing. thing.js has the following property :
owner: DS.belongsTo('user')
If I have foo with an empty owner, how can I, with only foo and the 'owner' string, retrieve the value 'user' representing the model of the owner relation?
EDIT: I want to allow my select-relation component to works with relations where the name is different from the class name
It sounds like you have some work to do to finish setting up your relationships. Have a read through this page of the guides.
If the relationships are set up correctly, to get the associated user, you should be able to do foo.owner. This assumes that users are already present in the store. I recommend using the Ember Inspector browser plugin to debug the relationships.
This looks like a use case for typeForRelationship.
In your example you should be able to do something like
store.modelFor('thing').typeForRelationship('owner', store);
If you don't like that approach you can use the belongsTo reference API, where you use the meta data from the relationship to get the type
foo.belongsTo('owner').type
The only thing with that approach is that the type property may not be public API and possible (though unlikely) to change at some point.
It seems I can do the following :
this.get('model').get('_internalModel._relationships.initializedRelationships.'+this.get('relation')+'.relationshipMeta.type')
model being an instance and relation the string of the relation name, it correctly return the model of the relation.
EDIT : a better solution not using private API courtesy from the ember discord :
function getRelatedModelName(record, relationName){
let ParentModelClass = record.constructor;
let meta = get(ParentModelClass, 'relationshipsByName').get(relationName);
return meta.type;
}
If I have an ember model say Person with attributes like name, age, height, address etc, and I want to fetch all records in the model but only want name attribute in returned JSON (name is the only param needed, so no need to return all params of the model), then is there a way in Ember to do that? I searched for the query methods on Ember store but was not able to see any such example.
Thanks in advance.
You can try with
const listOfName = this.get('store').findAll('Person').mapBy('name')
For details refer
mapBy
So in rails we could find a record by name, id etc, similarly i want to do in ember without making a server request
I have a model called person{id, name}. If i want to peek a record by id i do this:
this.get('store').peekRecord('person', id)
which gives me the record based on id, but now i want to peek a record with a particular name, i tried something like this:
this.get('store').peekRecord('person', {name: "testname"})
which dose not seem to work.
i need a way peek a record using just the name
You can only peekRecord using the unique identifier for the model, which is id property. If you do want to make a request then queryRecord is what you want. but you don't want to make a request so the only choice is peekAll and filter the result,
let allRecord = this.get('store').peekAll('person');
let filteredResult = allRecord.filterBy('name','testname');
//filteredResult is an array of matching records
I have this field in my domain object
#Field
#Enumerated(EnumType.STRING)
private SectionType sectionType;
but when I check the value stored in Solr it is something like:
com.x.y.objects.SectionType:H_HPI
What I want is just H_HPI or it is as if I'm calling specialty.name() method
Also I want a serializer that does that for all the enum fields in my domain objects.
I know that for neo4j, for instance, has such a serializer and can be supplied to the field as an annotation. Also mongodb does the conversion automatically.
I had same problem and found this from Spring Data Solr codes
else if (fieldValue instanceof Enum) {
field.setValue(this.getConversionService().convert(fieldValue, String.class), 1f);
}
it sets the String value
https://github.com/spring-projects/spring-data-solr/commit/4bf0af3344ec9e92ac241eaa25883e73b08f3b0b