Giter VIP home page Giter VIP logo

Comments (4)

james-ingold avatar james-ingold commented on June 5, 2024 1

Oh my gosh, I think the issue was that I had a custom field named status causing the issue or maybe it was just posting as a PUBLISH status but I am good now, it is working. Thank you so much for your help!

from wp-graphql-acf-mutations.

ditto-vlad avatar ditto-vlad commented on June 5, 2024

@james-ingold

Hello, yes. The acf-meta values should also be available for creating and updating. Can you elaborate more on the issue you are facing by providing the acf fields code as well :)

from wp-graphql-acf-mutations.

james-ingold avatar james-ingold commented on June 5, 2024

Hello, thanks for the reply! Sorry I'm a bit of a wordpress noob so I might be overlooking something simple. What do you mean by acf fields code? I might be missing that part. I have a custom post type and then I added acf fields to it in the wordpress admin panel and then added this plugin. If I have an item created already, I can use the updateItem mutation to update the acf fields and that works.
However if I use the createItem mutation, none of those acf fields are saved and the item doesn't appear in the Items list in wordpress. I see the item in the wp_posts table with a status of available but there are no rows for the meta fields for that item, I can see rows for the meta data for the one that was created from the wordpress admin panel.

from wp-graphql-acf-mutations.

ditto-vlad avatar ditto-vlad commented on June 5, 2024

@james-ingold

I have just verified using the examples below and it does work. One point to note is to use status: PUBLISH in order to see it using a simple query.

As to why you cant see it in the postmeta, finding the post meta for a specific post_id. this will filter it :)

Hope this helps

register_post_type(
        "github_test",
        [
            "label" => __("Github Test", "github-test"),
            "public" => true,
            "publicly_queryable" => true,
            "show_in_graphql" => true,
            "graphql_single_name" => "gTest",
            "graphql_plural_name" => "gTests"
        ]
    );
acf_add_local_field_group(array(
	'key' => 'group_627a40880bc1e',
	'title' => 'Github_Issue_Test',
	'fields' => array(
		array(
			'key' => 'field_6357a5685c42a',
			'label' => 'extra name',
			'name' => 'extra_name',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'show_in_graphql' => 1,
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
			'maxlength' => '',
		),
	),
	'location' => array(
		array(
			array(
				'param' => 'post_type',
				'operator' => '==',
				'value' => 'github_test',
			),
		),
	),
	'menu_order' => 0,
	'position' => 'normal',
	'style' => 'default',
	'label_placement' => 'top',
	'instruction_placement' => 'label',
	'hide_on_screen' => '',
	'active' => true,
	'description' => '',
	'show_in_rest' => 0,
	'show_in_graphql' => 1,
	'graphql_field_name' => 'github_meta_fields',
	'map_graphql_types_from_location_rules' => 0,
	'graphql_types' => '',
));
query MyQuery3 {
  gTests {
    nodes {
      title
      github_meta_fields {
        extraName
      }
    }
  }
}

mutation GithubTestCreate {
  createGTest(input: {status: PUBLISH, title: "test1", extraName: "extraName1"}) {
    gTest {
      github_meta_fields {
        extraName
      }
    }
  }
}

from wp-graphql-acf-mutations.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.