Skip to content

Navigation Menu

Sign in
Sign up

Make it possible for scalar annotation to register Doctrine and PHP types to map - #751

Open
bartv2 wants to merge 2 commits into
overblog:master from
bartv2:add-scalar-type-registration
Open

Make it possible for scalar annotation to register Doctrine and PHP types to map #751
bartv2 wants to merge 2 commits into
overblog:master from
bartv2:add-scalar-type-registration

Conversation

@bartv2

@bartv2 bartv2 commented Aug 20, 2020

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Documented? not yet
License MIT

When creating a scalar class it should be easy to also tell which types always map to this scalar. When the idea is accepted i will also update the documentation.

Vincz commented Aug 21, 2020

Copy link
Copy Markdown
Contributor

Hey @bartv2 !

I like the PHP types <-> Scalar conversion, but I don't like the fact that we would need to dive into the app code to check which PHP type convert to which Scalar.
At the moment, we can add Doctrine types conversion with https://github.com/overblog/GraphQLBundle/blob/master/docs/annotations/index.md#field-type-auto-guessing-from-doctrine-orm-annotations.
Can't we do what you want in the config as well ?
Something like :

overblog_graphql:
 php:
 types_mapping:
 DateTime: ScalarWithTypeMapping

Or maybe, am I missing something ?

bartv2 commented Aug 21, 2020

Copy link
Copy Markdown
Contributor Author

I was adding a scalar type and it wasn't working directly. These mappings are only used for the auto-guessing, i think. And with annotations (most of) the config will already be in the php code.

This PR also makes it possible to register the doctrine mapping in the annotation, maybe you didn't notice that. So all the mapping data can still be in one place.

Adding the php mapping to the config is a good idea for those who prefer that.

Comment thread tests/Config/Parser/fixtures/annotations/Type/CustomScalarType.php Outdated
Co-authored-by: Timur Murtukov <murtukov@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@murtukov murtukov murtukov left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /