GithubHelp home page GithubHelp logo

axtiva / flexible-graphql-php Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 167 KB

Schema SDL first lib for generate php code from graphql sdl to TypeRegistry with webonyx/graphql-php

License: MIT License

PHP 100.00%
apollo-federation apollo-federation-subgrapgh code-generation graphql graphql-server php sdl

flexible-graphql-php's Introduction

Axtiva Flexible Graphql

Schema first lib for generate php code from graphql sdl to TypeRegistry whom support webonyx/graphql-php with simple integrate to any controller.

TL;DR

Can easy to integrate graphql to any project, all you need is controller. Fast start with example

Features:

Setup

Composer install:

composer require axtiva/flexible-graphql-php

Examples:

Demo

Up Dev server for test http Graphql requests:

php -S localhost:8080 example/start_graphql_server.php

Change schema and run example commands

Update TypeRegistry and model classes from schema and resolvers map:

php example/generate_code.php

If you need to make field resolver, then remove AutoGenerationInterface from model CodedCurrencyType

Example:

- final class CodedCurrencyType implements AutoGenerationInterface, NodeInterface, CurrencyInterface
+ final class CodedCurrencyType implements NodeInterface, CurrencyInterface
{
    public string $id;
-   public int $code;
}

and run php example/generate_code.php, after this you will find in example/Resolver/CodedCurrency/CodeResolver.php. this is your field resolver, define him in your psr container like PsrContainerExample in example/start_graphql_server.php:

$container = new PsrContainerExample([
    \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\Query\AccountResolver::class =>
        new \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\Query\AccountResolver,
+   \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\CodedCurrency\CodeResolver::class =>
+       new \Axtiva\FlexibleGraphql\Example\GraphQL\Resolver\CodedCurrency\CodeResolver,
]);

Run demo app php -S localhost:8080 example/start_graphql_server.php and try request CodedCurrency.code field in query

Tests

Run tests

php vendor/bin/phpunit 

flexible-graphql-php's People

Contributors

bpteam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

visionp

flexible-graphql-php's Issues

Test this library against apollo-federation-subgraph-compatibility

I see this library has Federation 2 support, which is something that other libraries are struggling with:

As this library (up to my research) seems to be the only PHP one that provides Federation 2 support, what about testing that support against the schemas and making sure that this library thereafter gets the visibility it deserves by adding it to the GraphQL documentation pages?

Testing the implementation should be possible by adding it to
https://github.com/apollographql/apollo-federation-subgraph-compatibility/tree/main/implementations/php
... an example on how compatibility was tested by Skillshare can be found at Skillshare/apollo-federation-subgraph-compatibility#1

subscription support

I see the README says: Support all features from webonyx/graphql-php

Has subscription support been added? I haven't seen it in the change logs.

Running commands doesn't create Transaction folder

I removed the /GraphQL folder and attempted to rebuild the folder using the commands provided under 'examples' in the README.

Issue: Running the php files provided under 'examples' in the README doesn't create the folders or associated files for examples/GraphQL/Resolver /Transaction and examples/GraphQL/Resolver/Account. My assumption is that these are created when running php examples/generate_field_resolver.php

How can I rebuild the entire GraphQL folder using the schema.graphql file?

Error after upgrade from v1.1.3 to v2.1.0

Iā€™m having issue updating axtiva/flexible-graphql-php to latest version. After update and TypeRegistry.php re-generation Iā€™m getting error: Call to protected GraphQL\Type\Definition\FieldDefinition::__construct() from scope tnet\api\GraphQL\TypeRegistry
Any idea how to solve this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.