PHP code example of radic / graphql_streams_api-module

1. Go to this page and download the library: Download radic/graphql_streams_api-module library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

radic / graphql_streams_api-module example snippets


return [
    // other config options redacted, check out the documentation for a full overview
    'default_field_resolutions' => [
        'anomaly.field_type.addon'       => 'String',
        'anomaly.field_type.blocks'      => 'String',
        'anomaly.field_type.boolean'     => 'Boolean',
        'anomaly.field_type.checkboxes'  => 'Boolean',
        'anomaly.field_type.colorpicker' => 'String',
        //etc...
    ],
    'stream_bindings'           => [
        // namespace::slug
        'users::users'                 => [

            // generator results: type User {}
            'type_name'   => 'User',

            // PyroCMS Stream field assignment => GraphQL field type
            'resolutions' => [
                // custom type resolutions
                'id'         => 'ID',
                'roles'      => '[UserRole!] @hasMany',
                'created_at' => 'Date',
                'updated_at' => 'Date',
                'deleted_at' => 'Date',

                // The fields below will be resolved using the `default_field_resolutions`
                // If you want, you can assign a custom type resolutions like above
                'username',
                'display_name',
                'first_name',

                // protect fields by requiring authentication and permissions
                'email' => 'String @role(roles: ["admin"], operator: "AND")',
                'email' => 'String @role(roles: ["user", "guest"], operator: "NOT")',
                'email' => 'String @role(roles: ["admin", "user"], operator: "OR")',
                'last_name',
                'activated',
                'enabled',
            ],
        ],
        // other streams...
    ]
];


'stream_bindings' => [
    // '{namespace}::{slug}'
    'users::users' => [
        'type_name'   => 'User', // The resulting GraphQL schema type name.
        'resolutions' => [
            'slug',
            'title',
            'roles' => '[UserRole!] @hasMany',
        ]
    ],
    'users::roles' => [
        'type_name'   => 'UserRole',
        'resolutions' => [
            'slug'
        ]
    ]
]

php artisan api:generate

php artisan addon:install radic.module.graphql_streams_api

php artisan api:publish

php artisan api:generate