olragon / graphql_api

GraphQL for Drupal 7
GNU General Public License v2.0
13 stars 3 forks source link

Cannot convert addressfield to GraphQL type #2

Closed klokie closed 7 years ago

klokie commented 7 years ago

Hi! This looks like a really promising project. Trying to get up and running, but I ran into the following error, related to use of an Address Field I'm using. Any idea how I can avoid this, other than by deleting the offending field?

Cannot convert addressfield to GraphQL type. Array
(
    [entity_type] => profile2
    [bundle] => contributor
    [property] => field_address
    [info] => Array
        (
            [label] => Address
            [type] => addressfield
            [description] => Field \"field_address\".
            [getter callback] => entity_metadata_field_verbatim_get
            [setter callback] => entity_metadata_field_verbatim_set
            [access callback] => entity_metadata_field_access_callback
            [translatable] => 
            [field] => 1
            [required] => 
            [auto creation] => addressfield_auto_creation
            [property info] => Array
                (
                    [country] => Array
                        (
                            [label] => Country
                            [options list] => _addressfield_country_options_list
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [name_line] => Array
                        (
                            [label] => Full name
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [first_name] => Array
                        (
                            [label] => First name
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [last_name] => Array
                        (
                            [label] => Last name
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [organisation_name] => Array
                        (
                            [label] => Company
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [administrative_area] => Array
                        (
                            [label] => Administrative area (i.e. State / Province)
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [sub_administrative_area] => Array
                        (
                            [label] => Sub administrative area
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [locality] => Array
                        (
                            [label] => Locality (i.e. City)
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [dependent_locality] => Array
                        (
                            [label] => Dependent locality
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [postal_code] => Array
                        (
                            [label] => Postal code
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [thoroughfare] => Array
                        (
                            [label] => Thoroughfare (i.e. Street address)
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [premise] => Array
                        (
                            [label] => Premise (i.e. Apartment / Suite number)
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                    [sub_premise] => Array
                        (
                            [label] => Sub Premise (i.e. Suite, Apartment, Floor, Unknown.
                            [description] => 
                            [type] => text
                            [getter callback] => entity_property_verbatim_get
                            [setter callback] => entity_property_verbatim_set
                        )

                )

        )

)
olragon commented 7 years ago

Please update graphql_api code

https://github.com/olragon/graphql_api/commit/266b9bb0a8e577970d869dcce6dbb6b8af16cd7c

klokie commented 7 years ago

Thanks for the quick response - and the huge commit! I updated, but now Schema throws an out of memory error (and I have 1GB of RAM allocated to PHP):

Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 16378 bytes) in …/sites/all/modules/contrib/graphql_api/src/Schema.php on line 364

Also, one problem that I had both before and after this commit, was that PHP couldn't instantiate Schema - I had to add the following to graphql_api_page_callback():

  require_once(GRAPHQL_API_PATH . '/src/Schema.php');

Is that because I'm using PHP 5.6?

klokie commented 7 years ago

Is that because I'm using PHP 5.6?

To answer my own question, this was apparently the cause. I upgraded to PHP 7.0 and the page renders without error. Thanks so much!

klokie commented 7 years ago

Oh, it looks like I still need the following in graphql_api_page_callback():

  require_once(GRAPHQL_API_PATH . '/src/Schema.php');

Otherwise, it throws

Error: Class 'Drupal\graphql_api\Schema' not found in graphql_api_page_callback() (line 41 of
               …/sites/all/modules/contrib/graphql_api/includes/graphql_api_page_callback.inc).

Is there a specific PHP setting needed in order to avoid the error?

olragon commented 7 years ago

Try to upgrade X Autoload to latest stable version, clear cache and let's me known the result. https://www.drupal.org/project/xautoload

klokie commented 7 years ago

That fixed it. Thanks so much!