草庐IT

graphql_collections

全部标签

javascript - GraphQL 能否在解析器中选择性地解析给定查询结果的字段?

我有以下REST端点:/orders/{id}returns{orderId,orderItem,customerId}/customers/{id}returns{customerId,firstName,lastName}我受限于这两个端点,它们将被包装在我的graphql模式中。我想要以下架构:typeOrder{orderId:ID!,orderItem:String,customer:Customer}typeCustomer{customerId:ID!firstName:String!lastName:String!}typeQuery{getOrder(id:Strin

javascript - 如何将两个依赖的 GraphQL 查询与 'compose' 结合起来?

已解决!我正在尝试合并两个相关的GraphQL查询。第一个应该获得一个ID,第二个应该使用那个ID。我读到compose的行为类似于flowRight(),但无论我以什么顺序放置查询,如果queryId低于queryDetails,queryDetail总是被跳过(如预期的那样)。无论我如何将我的代码放在一起,该变量都是未定义的。import{graphql,compose}from'react-apollo'importgqlfrom'graphql-tag'classHomeextendsComponent{constructor(props){super(props)consol

javascript - 云函数 : How to copy Firestore Collection to a new document?

我想在发生事件时使用CloudFunctions在Firestore中制作一个集合的副本我已经有了迭代集合并复制每个文档的代码constfirestore=admin.firestore()firestore.collection("products").get().then(query=>{query.forEach(function(doc){varpromise=firestore.collection(uid).doc(doc.data().barcode).set(doc.data());});});有更短的版本吗?一次复制整个集合? 最佳答案

javascript - GraphQL 嵌套查询定义

我正在尝试为我的查询创建树状结构,以摆脱像这样的查询peopleList,peopleSingle,peopleEdit,peopleAdd,peopleDeletecompanyList,companySingle,companyEdit,companyAdd,companyDeleteetc.最后我想发送这样的查询:querytest{people{list{idname}single(id:123){idname}}company{list{idname}single(id:456){idname}}}mutationtest2{people{create(data:$var){

javascript - 主干 collection.add 不工作

我有一个像这样的非常基本的设置:varMusicModel=Backbone.Model.extend({});varPlaylistCollection=Backbone.Collection.extend({model:MusicModel,events:{'add':'add'},add:function(mdl){//Thisisworkingperfectlyfineevenoutputofmodelconsole.log(mdl);}});varplaylistCollection=newPlaylistCollection();playlistCollection.add

javascript - GraphQL/中继架构无法查询类型 "store"上的字段 "CreateLinkPayload"

我可以使用CURL和GraphiQL工具成功地进行graphql/relay查询和突变:然而,在我的react/中继应用程序中,我可以查询并将数据输入应用程序,但是每次我尝试改变我的应用程序中的某些内容时,我都会在控制台中收到此错误:bundle.js:51511UncaughtError:GraphQLvalidationerror``Cannotqueryfield"store"ontype"CreateLinkPayload".``infile`/Users/johndoe/react-relay-project/src/mutations/CreateLinkMutation.

JavaScriptSerializer 反序列化对象 "collection"作为对象中的属性失败

我有一个结构如下的js对象:object.property1="somestring";object.property2="somestring";object.property3.property1="somestring";object.property3.property2="somestring";object.property3.property2="somestring";我正在使用JSON.stringify(object)通过ajax请求传递它。当我尝试使用JavaScriptSerializer.Deserialize作为字典反序列化时,出现以下错误:没有为“Syst

javascript - 如何在 Vanilla JS 中使用 Apollo Client 创建 GraphQL 订阅

最近ApolloClient发布了一个websocket订阅功能,但到目前为止我只看到它是通过在componentWillMount生命周期Hook中使用subscribeToMore启动查询来使用的。这是取自https://dev-blog.apollodata.com/tutorial-graphql-subscriptions-client-side-40e185e4be76#0a8f的示例constmessagesSubscription=gql`subscriptionmessageAdded($channelId:ID!){messageAdded(channelId:$c

javascript - 主干 - Collection.add()/Collection.create() 之间的区别?

我对两者之间的差异感到很困惑。似乎Collection.create()(触发add和sync事件)可以看作是Collection.add()(触发add>)和Model.save()(触发sync)?以上评价是否正确?我错过了什么? 最佳答案 没错。是一种捷径。Documentationstates:createcollection.create(attributes,[options])Conveniencetocreateanewinstanceofamodelwithinacollection.Equivalenttoins

javascript - 如何从需要返回语句的 GraphQL 解析器中调用异步 node.js 函数?

graphql.org/graphql-js上提供的HelloWorld示例创建一个简单的GraphQL实现如下:var{graphql,buildSchema}=require('graphql');//Constructaschema,usingGraphQLschemalanguagevarschema=buildSchema(`typeQuery{hello:String}`);//TherootprovidesaresolverfunctionforeachAPIendpointvarroot={hello:()=>{return'HelloWorld!';}};//Runt