express-graphql

Resolving nested data in express GraphQL

半世苍凉 提交于 2020-01-14 12:37:47
问题 I am currently trying to resolve a simple recipe list that has a reference to ingredients. The data layout looks like this: type Ingredient { name: String! amount: Int! unit: Unit! recipe: Recipe } type Recipe { id: Int! name: String! ingredients: [Ingredient]! steps: [String]! pictureUrl: String! } As I understand it, my resolvers should look like this: The first one resolves the recipes and second one resolves the ingredient field in the recipe. It can (from my understanding) use the

How to return an array of objects in GraphQL, possibly using the same endpoint as the one that returns a single object?

点点圈 提交于 2020-01-04 04:59:31
问题 I am making a GraphQL API where I would be able to retrieve a car object by its id or retrieve all the cars when no parameter is provided. Using the code below, I am successfully able to retrieve a single car object by supplying id as a parameter. However, in the case where I would expect an array of objects i.e. when I supply no parameter at all, I get no result on GraphiQL. schema.js let cars = [ { name: "Honda", id: "1" }, { name: "Toyota", id: "2" }, { name: "BMW", id: "3" } ]; const

Explanation for different implementations of resolver function in graphql

一曲冷凌霜 提交于 2020-01-01 19:06:44
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

Explanation for different implementations of resolver function in graphql

心已入冬 提交于 2020-01-01 19:06:29
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

Explanation for different implementations of resolver function in graphql

旧街凉风 提交于 2020-01-01 19:06:29
问题 I've been reading through the graphQL docs and found that they've explained the implementation of the graphql server in 2 ways: one using graphql-yoga which is a fully featured graphql server and another one is using graphql, express-graphql and express. In both cases, we pass the schema and resolver functions while creating the server instance. But the implementation of resolver function differs. While using graphql-yoga, the resolver function is provided with 4 arguments which contains

GraphQL & Pulling Data from Oracle DB: Query Responds with the Resultset and Doesn't Come to The Graphql resolver Window

怎甘沉沦 提交于 2019-12-25 01:19:17
问题 I am new to GraphQL. Started developing an GraphQL app to pull the data from oracle database. It is very simple application. The query responds with the resultset and can be seen results in console.log ; however, it doesn't come to the graphql window (response/resolver window). It throws the error Cannot return null for non User.email I tried the promise in the oracle connection. Not sure, why it is not showing the data in GraphQL. UserType.js module.exports = new GraphQLObjectType({ name:

GraphQL [graphql js] circular dependencies: The type of * must be Output Type but got: [object Object]

夙愿已清 提交于 2019-12-24 23:43:51
问题 EDIT added my solution as an answer ORIGINAL QUESTION i believe this issue has to do with circular dependencies. i spent the better half of last night and today trying everything i could find online but nothing seems to work. what i have tried: convert the fields prop to a function that returns a field object convert the relating fields (within the fields prop) into functions that return the type combining the two approaches above finally ending with require statements in place of the fields

Write dynamic schema for return same result in Graphql

烂漫一生 提交于 2019-12-16 18:03:12
问题 Currently this schema working properly and give required result type Personal{ userId:String name: String email: String } type Contact{ mobile_no:String email:String } type Address{ address:String lat:String long:String } getContact(userId: String): Contact getPersonal(userId: String): Personal getAddress(userId: String): Address But I want to return type Response { status: Boolean message: String data: [] } Return data with status and message key where data hold an array of Contact, Personal

GraphQL fetch data at Query level results in redundant/useless request

人走茶凉 提交于 2019-12-14 03:05:51
问题 We are implementing GraphQL service, which stands in front of several backend microservices. For example, we have a Product and each product has a list of history orders. Our backend server provides two REST APIs, one for product detail data, the other returns the history order list of a product. Our client app has two pages: one is the product detail page, the other is the history order list of a product. So, in the product detail page, we can only retrieve the detail data of the product,

Unknown column 'getContent.movie_id' in 'field list

好久不见. 提交于 2019-12-13 03:55:03
问题 my whole schema const Films = new GraphQLObjectType({ name: 'films', interfaces: () => [MovieStream], fields: () => ({ movie_id: { type: GraphQLString, }, id:{ type: GraphQLID }, name: { type: GraphQLString, }, }) }) Films._typeConfig = { sqlTable: "films", uniqueKey: 'id', } const MovieStream = new GraphQLInterfaceType({ name: 'MovieStream', fields: () => ({ id: { type: GraphQLID, }, movie_id: { type: GraphQLString, }, }) }) MovieStream._typeConfig = { sqlTable: "movie_streams", uniqueKey: