graphql-js

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

GraphQL: How to implement a GraphQLList of GraphQLObjectTypes

吃可爱长大的小学妹 提交于 2020-01-14 03:43:06
问题 I have an issue with GraphQL (Specifically, implementing GraphQLList) I have a query getItemByName that correctly returns an Item , with Type itemType . But I haven't been able to implement a getItemList (Or a proper example btw). I know that it's supposed to have a type that implements GraphQLList. But am i doing it right? What's the data format that resolve should recieve? (Or that getItems() should return). An array of objects? Should those objects be implementing "itemType" definition?

How to use subscription of GraphQL in Graphql.js

浪尽此生 提交于 2020-01-12 11:10:33
问题 I am using relay-fullstack. It's using GraphQL.js . I want use subscription of GraphQL in GraphQL.js . But I can't find documents about subscription of GraphQL in GraphQL.js. Can I use subscription of GraphQL in GraphQL.js ? Or does not it support that? 回答1: Yes you can! I created a simple repository based on Facebook relay-examples todo relay modern with subscriptions support (server and client), you can check it out, I might also improve it in the future: https://github.com/jeremy-colin

How to use subscription of GraphQL in Graphql.js

ぐ巨炮叔叔 提交于 2020-01-12 11:08:26
问题 I am using relay-fullstack. It's using GraphQL.js . I want use subscription of GraphQL in GraphQL.js . But I can't find documents about subscription of GraphQL in GraphQL.js. Can I use subscription of GraphQL in GraphQL.js ? Or does not it support that? 回答1: Yes you can! I created a simple repository based on Facebook relay-examples todo relay modern with subscriptions support (server and client), you can check it out, I might also improve it in the future: https://github.com/jeremy-colin

Dynamic generate GraphQL schema supports

醉酒当歌 提交于 2020-01-12 05:54:36
问题 Is it possible to dynamically create a GraphQL schema ? We store the data in mongoDB and there is a possibility of new fields getting added. We do not want any code change to happen for this newly added field in the mongoDB document. Is there any way we can generate the schema dynamically ? Schema is defined in code, but for java(schema as pojo), when new attribute is added, you have to update and recompile code, then archive and deploy the jar again. Any way to generate schema by the data

Share common fields between Input and Type in GraphQL

拟墨画扇 提交于 2020-01-09 11:52:44
问题 I was wondering if there's a way to share the common fields between Input and Type in GraphQL so that I don't have to define the same set of fields in multiple places. Example: input PersonInput { id: String! name: String address: String } type Person { id: String! name: String address: String } I know Fragment might be a solution, but if my understanding is correct, using Fragment always requires you to put an ON condition which makes it look like this: Fragment PersonCommonFields on Person

Share common fields between Input and Type in GraphQL

£可爱£侵袭症+ 提交于 2020-01-09 11:52:24
问题 I was wondering if there's a way to share the common fields between Input and Type in GraphQL so that I don't have to define the same set of fields in multiple places. Example: input PersonInput { id: String! name: String address: String } type Person { id: String! name: String address: String } I know Fragment might be a solution, but if my understanding is correct, using Fragment always requires you to put an ON condition which makes it look like this: Fragment PersonCommonFields on Person

Connection is based on `array`,is this a design style guide for design a relay server?

馋奶兔 提交于 2020-01-05 09:09:41
问题 In connection/arrayconnection.js , It seems all the function is tend to work with array . For example: offsetToCursor is the only way to generate Cursor. Does this mean its a design pattern i must follow, or imply that i should generate Cursor by myself when using something other than array .If im planning to use Mongodb,should i make the database interface like an static array ? BTW: As a newbie to web develop, im a bit confused how to implement a qualified relay server. Are there some guide

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

How to transpile a Relay query from TypeScript to ES5?

自闭症网瘾萝莉.ら 提交于 2020-01-04 02:19:08
问题 I'm writing a web app in TypeScript. The app uses React and Relay from Facebook. My TypeScript source code gets compiled into ES6 code using the TypeScript compiler TSC. Then, the ES6 code gets transpiled into ES5 code using Babel. In order for Relay to work in the browser, a Babel plugin needs to transform the Relay GraphQL queries: https://facebook.github.io/relay/docs/guides-babel-plugin.html. The problem is, because TSC first transpiles these queries, the Babel Relay plugin doesn't