Git Product home page Git Product logo

graphql-base-module's Introduction

oxid-esales/graphql-base

Build Status Build Status

Stable Version Latest Version PHP Version

This module provides:

  • a basic GraphQL implementation for the OXID eShop
  • authorization and authentication using JWT
  • a query to log you in and get a JWT for further authentication

Documentation

  • Full documentation, including GraphQL schema, can be found here.

Usage

This assumes you have OXID eShop (at least OXID-eSales/oxideshop_ce: v7.1.0 component, which is part of the 7.1.0 compilation) up and running.

Branch Compatibility

  • 9.x versions (or b-7.1.x branch) are compatible with latest shop compilation 7.1.x resp. b-7.1.x shop compilation branches
  • 8.x versions (or b-7.0.x branch) are compatible with latest shop compilation: 7.0.x resp. b-7.0.x shop compilation branches
  • 7.x versions (or b-6.5.x branch) are compatible with latest shop compilations: 6.5.x resp. b-6.5.x shop compilation branches
  • 6.x versions (or b-6.4.x branch) are compatible with latest shop compilations: 6.4.x resp. b-6.4.x shop compilation branches
  • 5.x versions (or b-6.3.x branch) are compatible with latest shop compilations: 6.3.x resp. b-6.3.x shop compilation branches (NOTE: no support for PHP 8 yet)

Install

# Install desired version of oxid-esales/graphql-base module, in this case - latest released 9.x version, While updating the version you should add additional flag --with-all-dependencies with below command.
$ composer require oxid-esales/graphql-base ^9.0.0 --with-all-dependencies

You should run migrations both after installing the module and after each module update:

$ vendor/bin/oe-eshop-doctrine_migration migrations:migrate oe_graphql_base

After requiring the module, you need to activate it, either via OXID eShop admin or CLI.

$ bin/oe-console oe:module:activate oe_graphql_base

Update

If you when to update this module from older version to new version. Then run below command to ensure that all dependencies including in the composer.lock are updated that are compatible with each other.

$ composer update --with-all-dependencies

How to use

You can use your favourite GraphQL client to explore the API, if you do not already have one installed, you may use Altair GraphQL Client.

To login and retrieve a token send the following GraphQL query to the server

query {
    token (
        username: "[email protected]",
        password: "admin"
    )
}

You could simply fire up your terminal and use curl to do a basic check if the GraphQL base module is up and running as expected. To retrieve a valid token you need to replace the username and password below with valid login credentials.

$ curl http://oxideshop.local/graphql/ \
  -H 'Content-Type: application/json' \
  --data-binary '{"query":"query {token(username: \"[email protected]\", password: \"admin\")}"}'

You should see a response similar to this:

{
    "data": {
        "token": "a-very-long-jwt"
    }
}

This token is then to be send as your authorization with every request in the HTTP Authorization header like this:

Authorization: Bearer a-very-long-jwt

How to extend

The information on extending any module can be found in the OXID eSales documentation.

How to extend GraphQL module types and implement your new mutations and queries is shown in OXID GraphQL API documentation.

Testing

Syntax check and static analysis

$ composer static

Unit/Integration/Acceptance tests

  • install this module into a running OXID eShop
  • reset shop's database
$ bin/oe-console oe:database:reset --db-host=db-host --db-port=db-port --db-name=db-name --db-user=db-user --db-password=db-password --force
  • run Unit/Integration tests
$ ./vendor/bin/phpunit -c vendor/oxid-esales/graphql-base/tests/phpunit.xml
  • run Acceptance tests
$ SELENIUM_SERVER_HOST=selenium MODULE_IDS=oe_graphql_base vendor/bin/codecept run acceptance -c vendor/oxid-esales/graphql-base/tests/codeception.yml

Issues

To report issues with GraphQL module please use the OXID eShop bugtracking system.

Contributing

You like to contribute? ๐Ÿ™Œ AWESOME ๐Ÿ™Œ
Go and check the contribution guidelines

Build with

License

OXID Module and Component License, see LICENSE file.

graphql-base-module's People

Contributors

alfredbez avatar angel-dimitrov avatar benjaminjoerger avatar hkreuter avatar juergen-busch avatar karmrt avatar kermie avatar marceloxid avatar michaelkeiluweit avatar mtkoltan avatar nikolaivanovski avatar oxsteven avatar rahathameed avatar realflowcontrol avatar sieg avatar skoczekj avatar titakoleva avatar tkcreateit avatar vanilla-thunder avatar zckman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.