Array of objects from REST in a GraphQL - graphql-js

Trying to wrap a RESTAPI with a graphQL but not able to put the response of API (an array of objects) in a graphQL Type. Can anyone help me with how to put an array of object in graphQL type and then resolve?

Related

Data from nested DTOs in NestJS are not fetched and not visible

I'm new in NestJS.
I'd like to build DTO with nested DTO (array). The issue is that the array's data(from ParentsArray) is not fetched. I don't see it while debugging. Any help is appriciated!
In swagger the structure is like it should be
while debugging, the data entered in swagger to the nested array object is not visible:
what should I do to have access to this data?

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.

MongoDB Realm GraphQL - returning multiple types as custom payload in a custom resolver

I am currently exploring MongoDB Realm, more specifically the GraphQL integration. I have successfully created resolvers which return a specific type, or an array of one type. However, I can't figure out how to return arrays of multiple types...
I have tried to create a custom payload, but I have to define that payload as JSON, and can't reference non-JSON types from in there.
To clarify:
I can create a custom resolver which resolves: {shirts: [Shirts]}
I cannot create a custom resolver which resolves: {shirts: [Shirts], trousers: [Trousers], shoes: [Shoes]}
I cannot create a custom resolver which resolves: {shirts: [Shirts], isFoo: Boolean}
Is there any way to accomplish the latter two? I would be able to do it if I was allowed to edit the GraphQL schema directly, but as far as I can see, one is only able to modify the schema through this custom resolver interface...
Thanks in advance!

FOSElastica + FosRest + Doctrine + REST Api

Versions
Symfony 2.8.2
FosElastica 3.1.8
FosRest 1.7.7
Doctrine 2.5.4
Problem
Hello,
I have some MYSQL's tables with many relations. I would like a build a REST Api, in HTMl a JSON, to get them.
It is working in HTML, but doesn't in JSON.
Indeed, in JSON I am returning array with multi dimensional, and doctrine made each request to get data.
This maneuver makes many times and fail.
The solution will be to make a SQL join with the return of ElasticSearch but I don't how to make that.
Any idea?
The better solution is to make a REST API.
REST API never reterning a deep JSON Object, but only the asked object.
For instance one Entity People containing a list of Cars.
You have to make routing something like that :
Returning all users as light object (only id ans very important informations) :
/users
Returning one Full User WITHOUT his cars :
/users/{userId}
Returning full list if cars (as light objects) :
/users/{userId}/cars
Returning full car object (without sub object obviously) :
/users/{userId}/cars/{carId}
After you can manage your routing as you want with RESTFull

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.