Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks enhancement #851

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Conversation

mcg-web
Copy link
Member

@mcg-web mcg-web commented May 20, 2021

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no (at least for now)
Tests pass? yes
Documented? todo
Fixed tickets #708
License MIT

This PR is a proposal of how we could move forward for making expression language optional and simplifying config callbacks.

before:

Query:
    type: object
    config:
        fields:
            user:
                type: User
                resolve: '@=query("query")'

User:
    type: object
    config:
        fields:
            name:
                type: String
                description: "the user name"
            friends:
                type: friendConnection
                argsBuilder: "Relay::Connection"
                resolve: '@=query("friends", value, args)'
            friendsForward:
                type: userConnection
                argsBuilder: "Relay::ForwardConnection"
                resolve: '@=resolver("friends", [value, args])'
            friendsBackward:
                type: userConnection
                argsBuilder: "Relay::BackwardConnection"
                resolve: '@=resolver("friends", [value, args])'

friendConnection:
    type: relay-connection
    config:
        nodeType: User
        resolveNode: '@=query("node", value)'
        edgeFields:
            friendshipTime:
                type: String
                resolve: "Yesterday"
        connectionFields:
            totalCount:
                type: Int
                resolve: '@=query("connection")'

userConnection:
    type: relay-connection
    config:
        nodeType: User
        resolveNode: '@=query("node", value)'

after:

Query:
    type: object
    config:
        fields:
            user:
                type: User
                resolver: 'Overblog\GraphQLBundle\Tests\Functional\App\Resolver\ConnectionResolver::resolveQuery'

User:
    type: object
    config:
        fields:
            name:
                type: String
                description: "the user name"
            friends:
                type: friendConnection
                argsBuilder: "Relay::Connection"
                resolver:
                    method: 'overblog_graphql.test.resolver.node::friendsResolver'
            friendsForward:
                type: userConnection
                argsBuilder: "Relay::ForwardConnection"
                resolver:
                    id: 'overblog_graphql.test.resolver.node'
                    method: 'friendsResolver'
            friendsBackward:
                type: userConnection
                argsBuilder: "Relay::BackwardConnection"
                resolver: 'overblog_graphql.test.resolver.node::friendsResolver'

friendConnection:
    type: relay-connection
    config:
        nodeType: User
        resolveNode: '@=query("node", value)'
        edgeFields:
            friendshipTime:
                type: String
                resolver: 
                    expression: "'Yesterday'"
        connectionFields:
            totalCount:
                type: Int
                resolver: '@=query("connection")'

@mcg-web mcg-web requested review from Vincz and murtukov May 20, 2021 07:52
@mcg-web mcg-web changed the base branch from 0.14 to master December 22, 2021 10:17
@mcg-web mcg-web closed this Dec 22, 2021
@mcg-web mcg-web reopened this Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants