Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Generate avro-schema for a query with directives #85

Closed
SudoBobo opened this issue Mar 15, 2018 · 4 comments
Closed

Generate avro-schema for a query with directives #85

SudoBobo opened this issue Mar 15, 2018 · 4 comments
Assignees
Labels
customer enhancement New feature or request prio2
Milestone

Comments

@SudoBobo
Copy link
Contributor

The proposal is to extend solution from #7, so it could handle directives (http://facebook.github.io/graphql/October2016/#sec-Type-System.Directives) in GraphQL queries.

@SudoBobo SudoBobo added enhancement New feature or request prio2 labels Mar 15, 2018
Totktonada pushed a commit that referenced this issue Mar 16, 2018
Fixes #8.

Backlog / related: #84, #85, #86, #88, #89 + some refactoring / code
deduplication.
@Totktonada Totktonada added this to the 0.0.1 milestone Apr 17, 2018
@Totktonada Totktonada modified the milestones: 0.0.1, 0.0.2 Jul 10, 2018
@SudoBobo SudoBobo self-assigned this Jul 11, 2018
@SudoBobo
Copy link
Contributor Author

SudoBobo commented Jul 12, 2018

I think we should just ignore include and skip directives and generate avro-schema like include condition is always true and skip condition is always false. Like this, "turn" first schema below into second and then use our common query->schema routine.

query user_by_order($first_name: String, $description: String,
        $include: Boolean) {
    order_collection(description: $description) {
        order_id
        description
        user_connection @include(if: $include,
                first_name: $first_name) {
            user_id
            last_name
            first_name
        }
    }
}

second:

query user_by_order($first_name: String, $description: String,
        $include: Boolean) {
    order_collection(description: $description) {
        order_id
        description
        user_connection (first_name: $first_name) {
            user_id
            last_name
            first_name
        }
    }
}

The reason for that is that include and skip directives are about data representation, not about data schema. Query directives are mainly the tool to make flexible queries and reduce overall number of written queries.
There are also should not be confusion with non-null property. include condition may be true but if the field is nullable we still can retrieve nothing. And again they are describing different things - representation and schema.

@opomuc
Copy link

opomuc commented Jul 12, 2018

@SudoBobo well,

directives are about data representation, not about data schema

that is correct. BUT: avro-schema is generated for the response of the query, thus must take directives into account. I can propose generate record* field in case of both skip and include, meaning the field may or may not be present in the response

@SudoBobo
Copy link
Contributor Author

Discussed with @Totktonada in chat , came to the same conclusion.

@Totktonada
Copy link
Member

It can be any nulllable type, not only record*. Any field can have a directive.

SudoBobo added a commit that referenced this issue Jul 18, 2018
Also fixed existing tests on directives - there was wrong
syntax, which worked somehow in some cases.
Added a little note into README on how to run specific test.

Closes #85
SudoBobo added a commit that referenced this issue Jul 18, 2018
'include' directives.

Also fixed existing tests on directives - there was wrong
syntax, which worked somehow in some cases.
Added a little note into README on how to run specific test.

Closes #85
SudoBobo added a commit that referenced this issue Aug 2, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85
SudoBobo added a commit that referenced this issue Aug 3, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85, closes #85
SudoBobo added a commit that referenced this issue Aug 3, 2018
multi-head connections,
Unions, Maps and directives

Also changed GraphQL Map type: now it has
subType = Map and name = values.type .. '_Map'
(Example: 'String_Map') This is to avoid name
clash.
Closes #200, closes #198, closes #197, closes
#85, closes #84
SudoBobo added a commit that referenced this issue Aug 6, 2018
SudoBobo added a commit that referenced this issue Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer enhancement New feature or request prio2
Projects
None yet
Development

No branches or pull requests

3 participants