Tag: graphql

Babel / Node / Relay / Webpackcaching?

通常: 这四个系统有caching吗? 如果是这样,清除每个方法是什么? 特别: 遇到了我们正在开发的反应应用程序的问题。 在本地开发时,我们看起来偶尔会遇到以下错误: “Invariant Violation:RelayQL:在运行时发生意外的调用,或者Babel变换没有设置,或者它没有识别这个调用站点,确保它被逐字地用作`Relay.QL`。 我没有注意到为什么/何时开始发生的任何特定的原因。 我终于find了一个黑客解决scheme,涉及到我参考引用的组件文件(进一步在错误味精,未显示),并删除里面的RelayQL片段 export default Relay.createContainer(PinterestShare, { fragments: { resource: () => Relay.QL` fragment on Resource { id title files { type images { medium { url width } } } } ` } }); 至 export default Relay.createContainer(PinterestShare, { fragments: { resource: () => Relay.QL` ` } […]

使用Passport FacebookvalidationApollo GraphQL API

我有一个客户端服务器和一个API,都使用阿波罗 。 当用户使用Facebooklogin时,我想向我的客户端服务器发送一个令牌,然后将这个令牌附加到对API所做的每个请求的头部。 没有使用会话。 下面是API的外观,当用户使用Facebooklogin(我也在后台检查数据库中的用户)时,这会成功生成令牌。 // API running on port 3010 app.use(expressJwt({ secret: authConfig.jwt.secret, credentialsRequired: false, getToken: req => req.cookies.id_token, })); app.use(passport.initialize()); app.get('/login/facebook', passport.authenticate('facebook', { scope: ['email'], session: false }), ); app.get('/login/facebook/return', passport.authenticate('facebook', { failureRedirect: 'http://localhost:3000/login', session: false }), (req, res) => { const expiresIn = 60 * 60 * 24 * 1; // 1 […]

主机:localhost。 不在证书的altnames中

服务器端渲染时出现错误。 RENDERING ERROR: { [Error: Network error: request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.xyz.io"] graphQLErrors: null, networkError: { [FetchError: request to https://api-dev.xyz.io/graphql failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:*.xyz.io"] name: 'FetchError', message: 'request to […]

如何将对象列表连接到Relay的节点

在GraphQL中,我有以下结构 # represents any node with GlobalIdField node(id: "uniqueIdOfNode") { } # represents actually logged user viewer { } 在示例MVC应用程序模式待办事项连接到查看器,所以当查询你只能得到属于login用户的待办事项。 但是,在我的情况下,我想要显示与用户无关的数据。 假设数据是types国家这是NodeInterfaceType,我想问一个查询国家的名单。 所以在Relay中,我可以在CountryList中创build一个片段,并使用Relay将其传递给React组件。 如果我写的不够清楚,就让我知道,因为我很困惑,而且我不确定我是否解释得好。 我用PHP编写了GraphQL服务器,但代码或提示可以用node.js编写,我也会理解它。 怎么做? 更新 一些代码: schema.graphql # A country type Country implements NodeInterface { # The ID of an object id: ID! countryId: Int phonePrefix: String name: String timezone: String } # […]

如何将GraphQL连接到MySQL

我已经使用快速cli来build立一个简单的快速项目,并遵循教程来创builddb.js和schema.js但在这一点上,我不能想到debugging这个错误/查看graphiql中的架构的任何部分文档。 { "errors": [ { "message": "Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory." } ] } App.js var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger = require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = […]

如何使用GraphQL将二进制数据发送回客户端

我有一个特快专递的GraphQL服务器。 我想通过发回nodejs缓冲区对象将图像返回给客户端。 我如何configurationgraphql服务器,返回字节,而不是json? 我不希望通过base64来做这个,因为图片的尺寸很大。

如何启用节点上的csrfexpression式为graphql和graphiql与例如lusca?

有一个节点与csrf lusca快递服务器,我想启用csrf也为graphql和graphiql,但如何做到这一点? const csrf = require('lusca').csrf() const graphqlExpress = require('graphql-server-express').graphqlExpress const graphiqlExpress = require('graphql-server-express').graphiqlExpress server.use((req, res, next) => { csrf(req, res, next) } }) server.use('/graphql', (req, res, next) => { graphqlExpress( () => { const query = req.query.query || req.body.query; return { schema, context: Object.assign({ user }, req.context), debug: false, formatError(e) { console.log(e) }, } […]

.gql或.graphql文件types与节点

我正在使用Apollo的graphql-server-express和Node,我想将我的“typedef”模式定义文件转换为.graphql or .gql文件,以提高清晰度和语法高亮度。 做这个的最好方式是什么? 除了Babel(?)之外,我无法find任何好的资源,这似乎是唯一的select。 非常感谢你的帮助!

如何发送从graphql的令牌请求到python api?

我需要从graphql发送授权请求到Python API,以便我可以与Python API通信。 在这个请求中,我需要发送用户的用户名和密码与Authorization标题和接收令牌将用于进一步沟通。 我不知道如何发送这个请求。 我已经创build了模式来进行通信,但是不知道如何添加这个部分。 这是我的代码的其余部分: Schema.js import { GraphQLSchema, GraphQLObjectType, GraphQLString, } from 'graphql'; import fetch from 'node-fetch'; const BASE_URL = 'http://localhost:9000/api'; function getUserByURL(relativeURL) { return fetch(`${BASE_URL}${relativeURL}`) .then(res => res.json()) .then(json => json.user) } const UserType = new GraphQLObjectType({ name: 'User', description: '…', fields: () => ({ firstName: { type: GraphQLString, resolve: (user) […]

GraphQL中继返回一条logging

我在我的项目中使用graphql-relay 在我的grapgql中运行这个查询时: { viewer{ boRelayCustomerInfo(_id:"59267769de82262d7e39c47c") { edges { node { id } } } } } 我给了这个错误: "message": "arraySlice.slice is not a function" 我的查询代码是: import { GraphQLID, GraphQLNonNull, } from 'graphql' import { connectionArgs, connectionFromPromisedArray, } from 'graphql-relay' import { customerConnection } from '@/src/schema/type/customer/CustomerType' import { CustomerModel, ObjectId } from '@/src/db' export default { type: […]