React GQL testing Error for MOCK PROVIDER - react-test-renderer

Invariant Violation: Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql

Related

GraphQL introspection query and generic parser

We wanted to build an application using the GraphQL API and trying to build dynamic discovery where we can query system and get the required objects/metadata (where CRUD can be performed). We know GraphQL provides introspection query, to query the schema. Below are the few query we have identified:
query IntrospectionQuery { __schema { types { name kind ofType { name kind }} } } - To get all the types. The problem with this query is that it returns all the types (including OBJECT, INPUT_OBJECT, other types). Not all objects are top level. How to differentiate between top level object on which CRUD can be performed.
Some endpoint have generic implementation for Query and Mutation, like a kind of abstract method (Query - businessObjects, Mutation - upsert). How we can derive and map the operations on the object identified above.
We wanted to build a common module which can be applied to any GraphQL endpoint.
Thanks in advance.

Understanding Firestore's Underlying Serialisation Mechanism

I would like to get some information on how the serialisation/deserialisation mechanism works in Firestore. The issue I am having is that I am passing a Scala (JVM language) object into the Firestore create method but it blows up at the point of serialising that data. After some investigation, it appears that Firestore requires values created from classes which have an empty public constructor, why is this a constraint? This is something that Scala classes do not have. Is there anyway to side-step Firestore's serialisation and provide my own?
Firestore requires values created from classes which have an empty public constructor, why is this a constraint?
When you load data from Firestore, you have the option to read a Java object from the document by calling DocumentSnapshot.toObject(Class<T> valueType). In order to create the object that it returns, the Firestore SDK must be able to call a constructor on the class that you pass in. And the only constructor it can reasonably call, is one without any arguments, as it has no way to determine what argument values to pass in otherwise.
Note that calling toObject is not the only option to create an object out of a DocumentSnapshot. You can also construct the Java object yourself, and extract the individual values from the snapshot by calling its get methods.
A quick search seems to hint that it is possible to add a no-argument constructor in Scala too, so I also recommend checking out:
Scala case classes with new firebase-server-sdk
A quick overview of using Firebase in a Scala application

Error creating bean with name 'customerRepository': Invocation of init method failed; No property updateCustomer found for type Customer

CRUD operations using Spring Boot + JPA + Hibernate + PostgreSQL
Please am new in this topic. Am trying to create a CRUD Api. Everything is ok but i cant get the UPDATE method using the JpaRepository. I dont have error when i build my project.
I try to code a specific createCustomer method into my customerRepository but still not working
enter image description here
enter image description here
But when i run it with maven i get this error:
Spring data Repository work mostly with method names. It creates query based on the method name. For example in your Repository interface you have a method findByUserId. This will work even if you have not written any query. How ?
spring-data will formulate the query to fetch the field specified after findBy (UserId in your case). But at compile time, it checks whether you are providing a valid field So that it can prepare a proper query. It does so by checking your entity class (Customer in your case) for this field.
Note : keep in mind that field in Entity is called userId but method name in Repository is called UserId.
The reason save, delete methods are working because you are extending JPARepository class(which in-turn extends other classes), which has these methods. So it works out of the box.
But when you write some method which is not there in any of the super class, then spring-data will try to formulate the query on its own as I specified earlier. So when you write a method like updateCustomer which is not in any of the super classes, then it tries to find in the entity class a field with name updateCustomer and it fails since it cannot find and hence the exception.
So if you want to declare or do something like this, you can do this by annotating such method with #Query(....) and providing the right query inside it.
#Query(update customer set ..........)
Customer updateCustomer(Customer customer)
Hope its clear.

Error when using tolower with OData REST API call: An entity member is invoking an invalid property or method

As suggested here and here, I should be able to apply tolower to do a case-insensitive field match with a REST call to the OrganizationData.svc endpoint.
Here's my GET request:
/XRMServices/2011/OrganizationData.svc/ContactSet?$filter=tolower(EMailAddress1) eq 'me#awesome.com'
And I get the following result:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>-2147220715</code>
<message xml:lang="en-US">
Invalid 'where' condition. An entity member is invoking an invalid property or method.
</message>
</error>
What am I doing wrong? How can I do a case-insensitive match on the EmailAddress1 field on the Contact entity using the REST endpoint?
(Note: I know I can change the SQL Server collation to case-insensitive but I need this to work for Dynamics online as well).
SOLUTION
So it looks like tolower is not supported at all in the OData implementation for the Dynamics REST API. If you need to do a case-insensitive match, the only way I found is to change the SQL Server database collation in an on-premise install.
For Dynamics online, you'd probably need to write a plugin that fires on entity create/update and converts the field to lower-case.
You would not be able to do that. By default all information (and in CRM Online) as well is stored in case-sensitive DBs so you just would not be able to do case insensitive search.

Implementing RESTful field query-string parameter

Based on the recommendation by APIGEE in their RESTful API Design blog post I wish to implement the fields query-string parameter to allow mobile application clients to restrict the content returned from a single RESTful API call. For example:
domain.site.com/rest/accounts/{id}?fields=name,id,age
If the fields parameter is omitted then a complete account resource will be returned. My question is how would I implement this on the server using Jersey (for example). Since Jersey makes it easy to return an Account POJO but I am unsure how to restrict the fields of the resulting JSON object based on the 'fields' query-string parameter.
There's not an automatic way to do it. Your service should load the entire object and then null out the fields you dont' want. Make sure the beans are annotated to ignore null fields in the json serialization and then return the object after you've modified it to remove the fields you dont' want.