Questions tagged [graphql-php]

graphql-php is a feature-complete implementation of GraphQL specification in PHP (5.5+, 7.0+). This library is a thin wrapper around your existing data layer and business logic.

38 questions
350
votes
6 answers

How to query all the GraphQL type fields without writing a long query?

Assume you have a GraphQL type and it includes many fields. How to query all the fields without writing down a long query that includes the names of all the fields? For example, If I have these fields : public function fields() { return…
BlackSigma
  • 3,505
  • 2
  • 15
  • 8
7
votes
4 answers

GraphQL GET response time is slow when comparing to RESTful

I wanted to test the response times of a GraphQL endpoint, and a RESTful endpoint as I haven't ever used GraphQL before, and I am about to use it in my next Laravel project. So I am using Lighthouse PHP package to serve a GraphQL endpoint from my…
Kazmi
  • 1,198
  • 9
  • 20
7
votes
1 answer

GraphQL filtering parent data in child resolver

I'm trying to figure out how to implement bottom up filtering in a parent-child relationship using GraphQL. Consider the following basic type hierarchy modelling a parking lot and available parking spots: type ParkingLot { id: Int! spots:…
horatiu
  • 193
  • 2
  • 10
7
votes
1 answer

Custom map keys in GraphQL response

I've been looking into GraphQL as a replacement for some REST APIs of mine, and while I think I've wrapped my head around the basics and like most of what I see so far, there's one important feature that seems to be missing. Let's say I've got a…
Dan Hlavenka
  • 3,697
  • 8
  • 42
  • 60
5
votes
4 answers

In Router.php line 366: Argument 1 passed to Illuminate\Routing\Router::group() must be of the type array,

I have update Laravel from v5.7 to v5.8 and now my application doesn't run. I updated it because of this issue: composer require rebing/graphql-laravel fails I solved the packages incompatibility but now Laravel crashes: $ php artisan serve In…
5
votes
4 answers

getting started in graphql-php: how to add resolver functions to schema from .graphql file?

I'm totally new to GraphQL and wanted to play arouund with graphql-php in order to build a simple API to get started. I'm currently reading the docs and trying out the examples, but I'm stuck quite at the beginning. I want my schema to be stored in…
Constantin Groß
  • 10,719
  • 4
  • 24
  • 50
5
votes
1 answer

zend 3, graphQL - how to create model instance using factory in Types class

Currently I have such Types.php: namespace Application\GraphQL; use Application\GraphQL\Type\NodeType; use Application\GraphQL\Type\QueryType; use GraphQL\Type\Definition\NonNull; use GraphQL\Type\Definition\Type; use…
Dariux
  • 3,953
  • 9
  • 43
  • 69
4
votes
1 answer

php graphQl "Field \"person\" argument \"id\" of type \"ID!\" is required but not provided.",

I am trying to fetch person object by the example there: https://github.com/webonyx/graphql-php/tree/master/examples/01-blog How should I debug this? IndexController.php public function indexAction() { if (!empty($_GET['debug'])) { …
Dariux
  • 3,953
  • 9
  • 43
  • 69
2
votes
0 answers

How to use inline fragments in GraphQL query thanks to ApiPlatform project and Doctrine Inheritance?

Thank you by advance for your help ! Before detailing my need, let me introduce the context : Project stack: tech/lib version php 8.1 symfony v6.1 api-platform v2.6 webonyx/graphql-php v14.11 Doctrine model/entities To simplify the…
lenybernard
  • 2,399
  • 22
  • 22
2
votes
2 answers

sort by related column in laravel lighthouse graphql

how can I sort by related column in laravel lighthouse graphql? For example, I have Products that have One Category but I can't SortBy Category. How can I do that? GraphQL getProducts(orderBy: _ @orderBy): [Product!]! @all type Product { id:…
Agustin
  • 215
  • 1
  • 2
  • 14
2
votes
2 answers

GraphQL Error : Method not allowed. Must be one of: OPTIONS

I am new with GraphQL. I need to make an API with PHP and GraphQL. I followed this tutorial: https://medium.com/swlh/setting-up-graphql-with-php-9baba3f21501 everything was OK, but when opening the URL, I got this error: { "statusCode": 405, …
Iheb Saad
  • 147
  • 1
  • 2
  • 15
2
votes
0 answers

graphql-php who to get result by id

l am a rookie of graphql, and l never used rest or other language like this. l can just get the fixed value with my level now. l have a schema file like follow demo.schema schema { query: Query } type Query { id(id: Int): sub } type sub{ …
afraid.jpg
  • 965
  • 2
  • 14
  • 31
2
votes
1 answer

GraphQL PHP full query path

I'm trying to implement authorization for graphql-php in my project. The idea is to have a user access array, where I can set access for each user group to specific queries and mutations, and implementing a check-access method in graphql controller,…
ElvisElvis
  • 160
  • 1
  • 12
1
vote
0 answers

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

Here i am creating an objectType object called Product new ObjectType([ 'name' => 'Product', 'fields' => fn() => [ 'databaseId' => [ 'type' => Type::Int(), ], ]); It is working fine... i am also creating a UnionType new…
1
vote
1 answer

How to properly serve custom queries with @method directive in lighthouse-php?

I am building an inventory application with lighthouse and struggling to grasp the concept of serving custom queries with complex logic on demand. This is and approximate query that I am trying to create: { statsReport { dailyTotalSales …
Andrius Solopovas
  • 967
  • 11
  • 41
1
2 3