zngly / wp-graphql-acf-mutations

WP GraphQl ACF Mutations Plugin
Other
7 stars 1 forks source link

Graphiql-ide page not loading after activating the plugin #10

Open davidmadon opened 2 years ago

davidmadon commented 2 years ago

Hi,

I'm running into a JS console error when trying to load the Graphiql-ide page in WP-admin after activating your plugin.

SCR-20221026-j8m

Requests to the API still seem to work properly.

Wordpress: Version 6.1 - RC3 Advanced Custom Fields PRO: Version 6.0.3 WP GraphQL: Version 1.12.0 WPGraphQL for Advanced Custom Fields: Version 0.6.1 WPGraphQL ACF Mutations: Version 1.1.1

zngly-vlad commented 2 years ago

Hello,

Have a look at the network tab as well and see if there is any more information on the error.

Could you provide more information on the acf fields you are using. I don't think I support all of them yet.

Thanks

davidmadon commented 2 years ago

Sure!

This is the response I'm getting in the network request on that page:

{
  "errors": [
    {
      "debugMessage": "GraphQL\\Type\\Schema::resolveType(): Return value must be of type GraphQL\\Type\\Definition\\Type, null returned",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 15,
          "column": 5
        }
      ],
      "path": [
        "__schema",
        "types"
      ],
      "trace": [
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Type/Definition/InputObjectField.php",
          "line": 121,
          "call": "GraphQL\\Type\\Schema::resolveType(instance of Closure)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 218,
          "call": "GraphQL\\Type\\Definition\\InputObjectField::getType()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 162,
          "call": "GraphQL\\Utils\\TypeInfo::extractTypes(GraphQLType: CreateEventInput, array(307))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Utils/TypeInfo.php",
          "line": 222,
          "call": "GraphQL\\Utils\\TypeInfo::extractTypes(GraphQLType: CreateEventInput, array(306))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 222,
          "call": "GraphQL\\Utils\\TypeInfo::extractTypes(GraphQLType: RootMutation, array(306))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Type/Schema.php",
          "line": 208,
          "call": "GraphQL\\Type\\Schema::collectAllTypes()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Type/Introspection.php",
          "line": 240,
          "call": "GraphQL\\Type\\Schema::getTypeMap()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "GraphQL\\Type\\Introspection::GraphQL\\Type\\{closure}(instance of WPGraphQL\\WPSchema, array(0), instance of WPGraphQL\\AppContext, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError(instance of GraphQL\\Type\\Definition\\FieldDefinition, instance of GraphQL\\Language\\AST\\FieldNode, instance of Closure, instance of WPGraphQL\\WPSchema, instance of GraphQL\\Type\\Definition\\ResolveInfo)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: __Schema, instance of WPGraphQL\\WPSchema, instance of ArrayObject(1), array(2))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1145,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: __Schema, instance of WPGraphQL\\WPSchema, array(1), instance of ArrayObject(6))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1106,
          "call": "GraphQL\\Executor\\ReferenceExecutor::collectAndExecuteSubfields(GraphQLType: __Schema, instance of ArrayObject(1), array(1), instance of WPGraphQL\\WPSchema)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 793,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeObjectValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\WPSchema)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 741,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\WPSchema)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 654,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValue(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\WPSchema)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 557,
          "call": "GraphQL\\Executor\\ReferenceExecutor::completeValueCatchingError(GraphQLType: __Schema, instance of ArrayObject(1), instance of GraphQL\\Type\\Definition\\ResolveInfo, array(1), instance of WPGraphQL\\WPSchema)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField(GraphQLType: RootQuery, null, instance of ArrayObject(1), array(1))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields(GraphQLType: RootQuery, null, array(0), instance of ArrayObject(1))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation(instance of GraphQL\\Language\\AST\\OperationDefinitionNode, null)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of WPGraphQL\\WPSchema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of WPGraphQL\\AppContext, array(0), 'IntrospectionQuery', null)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/Helper.php",
          "line": 311,
          "call": "GraphQL\\GraphQL::promiseToExecute(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of WPGraphQL\\WPSchema, instance of GraphQL\\Language\\AST\\DocumentNode, null, instance of WPGraphQL\\AppContext, array(0), 'IntrospectionQuery', null, array(29))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/Helper.php",
          "line": 211,
          "call": "GraphQL\\Server\\Helper::promiseToExecuteOperation(instance of GraphQL\\Executor\\Promise\\Adapter\\SyncPromiseAdapter, instance of GraphQL\\Server\\ServerConfig, instance of GraphQL\\Server\\OperationParams)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Server/StandardServer.php",
          "line": 136,
          "call": "GraphQL\\Server\\Helper::executeOperation(instance of GraphQL\\Server\\ServerConfig, instance of GraphQL\\Server\\OperationParams)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Request.php",
          "line": 713,
          "call": "GraphQL\\Server\\StandardServer::executeRequest(instance of GraphQL\\Server\\OperationParams)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 480,
          "call": "WPGraphQL\\Request::execute_http()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Router.php",
          "line": 274,
          "call": "WPGraphQL\\Router::process_http_request()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php",
          "line": 308,
          "call": "WPGraphQL\\Router::resolve_http_request(instance of WP)"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php",
          "line": 332,
          "call": "WP_Hook::apply_filters(null, array(1))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/plugin.php",
          "line": 565,
          "call": "WP_Hook::do_action(array(1))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp.php",
          "line": 399,
          "function": "do_action_ref_array('parse_request', array(1))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp.php",
          "line": 780,
          "call": "WP::parse_request((empty string))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/functions.php",
          "line": 1332,
          "call": "WP::main((empty string))"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/wp-blog-header.php",
          "line": 16,
          "function": "wp()"
        },
        {
          "file": "/Users/soulstream/Local Sites/united-soul/app/public/index.php",
          "line": 17,
          "function": "require('/Users/soulstream/Local Sites/united-soul/app/public/wp-blog-header.php')"
        }
      ]
    }
  ],
  "extensions": {
    "debug": [
      {
        "type": "DUPLICATE_TYPE",
        "message": "You cannot register duplicate Types to the Schema. The Type 'Template_Portalpage' already exists in the Schema. Make sure to give new Types a unique name.",
        "type_name": "Template_Portalpage",
        "stack": [
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php:624",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/access-functions.php:184",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:308",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:332",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/plugin.php:517",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php:530",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:308",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:332",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/plugin.php:517",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Registry/TypeRegistry.php:232",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Registry/SchemaRegistry.php:38",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/WPGraphQL.php:795",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Request.php:157",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Router.php:464",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-content/plugins/wp-graphql/src/Router.php:274",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:308",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp-hook.php:332",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/plugin.php:565",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp.php:399",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/class-wp.php:780",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-includes/functions.php:1332",
          "/Users/soulstream/Local Sites/united-soul/app/public/wp-blog-header.php:16",
          "/Users/soulstream/Local Sites/united-soul/app/public/index.php:17"
        ]
      }
    ],
    "tracing": {
      "version": 1,
      "startTime": 1666785890.089034,
      "endTime": 1666785890.320435,
      "duration": 231400,
      "execution": {
        "resolvers": []
      }
    },
    "queryLog": [
      "Query Logging has been disabled. The 'SAVEQUERIES' Constant is set to 'false' on your server."
    ],
    "queryAnalyzer": {
      "keys": "4635c4880d71342bbfbebde99495c79f graphql:Query",
      "keysLength": 46,
      "keysCount": 2,
      "skippedKeys": "",
      "skippedKeysSize": 0,
      "skippedKeysCount": 0,
      "skippedTypes": []
    }
  }
}

This is with debug activate in the GraphQL plugin. I'm pretty sure the DUPLICATE_TYPE warning in the end is unrelated. It was there before adding your plugin.

davidmadon commented 2 years ago

It's throwing JS errors in the ACF admin page when editing a field group as well:

SCR-20221026-kbb

davidmadon commented 2 years ago

Will try to activate the plugin in a test install without any fields and see if that makes a differens.

davidmadon commented 2 years ago

It works in my test install with 1 active text field so it's probably related to unsupported field types like you mention. Will add a few more to figure out which one it is.

davidmadon commented 2 years ago

Error gets triggered when I add the "Post Object" field type.

davidmadon commented 2 years ago

Upon closer inspection it's a slightly different error message:

SCR-20221026-l8t

davidmadon commented 2 years ago

It seems to be 2 issues:

The first error message "Internal server error" seem to be related to the Google maps field. Adding that breaks both the Graphiql IDE and the ACF field group edit page. (Will hold of using this field for now :)

The last message regarding the "PostObjectUnion" is when a Post Object field typ is set to return the whole Post Object. But it works if you set the return to "Post ID".

zngly-vlad commented 2 years ago

Yes, I use post ID internally, never tried it with postObject. I havent tried the google maps field before.

The Ide could do with better debugging support :)

Will look into fixing this when i get a chance. Thank you for pointing this out

davidmadon commented 2 years ago

Sure, no issue.

Thanks for building the plugin!

I might look into adding support for the Google Maps field myself, might need it later on in the project I'm working on. But for now some text fields will do just fine for the address :)

Side note: One thing I noticed when adding test fields is that if you save a field with empty "name" field it breaks the Graphiql IDE as well, which makes kind of sense. But it only happens with your plugin active so it seems the WPGraphQL for Advanced Custom Fields have some failsafe for this.

davidmadon commented 2 years ago

Any pointers on adding more field types to your plugin? Might be able to contribute

zngly-vlad commented 2 years ago

As to where in the code start here: https://github.com/zngly/wp-graphql-acf-mutations/blob/main/src/config.php#L371

I suggest forking the repo and submitting a pr.

This plugin is mainly used internally at Zngly. I am happy to expand the collaboration to whomever wishes to contribute 😄. If you have any tips on any improvements feel free to message me