问题标签 [graphql-php]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
191 浏览

laravel - Graphql:用户错误:预期可迭代,但没有为字段 XXX 找到一个

这是电影模式:

这就是我如何关联书籍和作者

这是作者的架构

这是我对书的查询:

这就是我查询的方式:

最后,这是我得到的错误消息:

“用户错误:预期可迭代,但没有为字段 Book.author 找到一个。”

如果我使用 hasMany 而不是 belongsTo,它可以正常工作。

请让我知道这里有什么问题?

0 投票
1 回答
341 浏览

php - Webonyx/Graphql-php 入门:如何在 cURL 中获取 API 的响应而不会从 API 实现中获得回声?

我是 GraphQL 的新手,想构建一个简单的 API 来开始。在阅读了文档并尝试了示例之后,API 终于可以正常工作了……但是!!!

API 的 php 实现以“回声”结尾(这对 Graphiql 客户端来说工作正常!),但是当我尝试在 cURL 中获取响应时,这个回声出现在我的页面源中......

请问各位,如何避免这种回声并在cURL中获得结果?我求助于巨大的集体智慧来获得一些帮助。

以下是我使用的资源:

这是webonyx/graphql-php的实现:

这里是GraphiQL中的查询:

这是GraphQL中的结果(一切正常!):

这是cURL中获取响应的函数:

这是我使用该功能时页面中的源代码:

字符串:{"data":{"addUser":{"id":98,"name":"user name"}}}来自 API 实现echo json_encode($output);

我尝试使用 get_file_content 而不是 cURL 但无法取得良好的效果,请提供任何帮助!

0 投票
0 回答
23 浏览

laravel - 有没有办法在 laravel 中获取特定模型的所有关系和字段?

我正在尝试创建一个脚本,该脚本可以帮助我生成模型中存在所有字段和关系的 GraphQL 模式。

如果我能做到这一点,php-lighthouse会帮助我完成剩下的工作。

0 投票
0 回答
18 浏览

php - PHP - GraphQL : How to add union type to object type

Here i am creating an objectType object called Product

It is working fine... i am also creating a UnionType

Here both AvatarType & UserType is an Object itself!!

I want to use this query as

Here RootQuery.products is Type::listOf( 'Product' )

How do i connect the Union SimpleProduct to Product ObjectType

Read some blogs about interfaces but not sure how to connect that Union to Object without using fields!! for example i saw blog articles as...

but that just give me...

How can i add Union directly to Object without using fields!!