Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions with arguments that are arrays of custom types are not parsed correctly #83

Closed
cookejames opened this issue Sep 26, 2017 · 13 comments
Labels
Milestone

Comments

@cookejames
Copy link

Here there are two arguments newPostContents and schedulesWithOptimal that are arrays of a custom types however they are shown as type string. Custom types that aren't arrays such as interactionType are interpreted correctly.

Do you have any suggestion where to start looking at the schema parsing code to fix this?
mutation
function

@benjie
Copy link
Member

benjie commented Sep 26, 2017

Can you provide a minimal pg_dump that reproduces this?

The issue most likely exists in this file, in that we cannot find or build a GraphQL type to match the PostgreSQL one:

https://github.com/graphile/graphile-build/blob/master/packages/graphile-build-pg/src/plugins/PgTypesPlugin.js

@benjie
Copy link
Member

benjie commented Sep 26, 2017

@cookejames
Copy link
Author

Thanks I will try and get a minimal dump that reproduces the problem and have a look at those files

@cookejames
Copy link
Author

This should be enough to reproduce the error with the createScheduledPost mutation
minimaltables.txt

@benjie
Copy link
Member

benjie commented Sep 26, 2017

[issue83] # \df
List of functions
-[ RECORD 1 ]-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Schema              | public
Name                | create_scheduled_post
Result data type    | posts
Argument data types | campaign_id uuid, new_post_contents new_post_content[], interaction_type interaction_types, schedule_datetimes character varying[], schedules_with_optimal schedules_with_optimal[], media_ids character varying[], approval_state approval_states DEFAULT 'published'::approval_states
Type                | normal

We can rule out graphile/crystal#580 at least; so that's good news!

[issue83] # select * from pg_type where typname like '%schedules_with_opt%';
-[ RECORD 1 ]--+------------------------
typname        | schedules_with_optimal
typnamespace   | 2200
typowner       | 10
typlen         | -1
typbyval       | f
typtype        | c
typcategory    | C
typispreferred | f
typisdefined   | t
typdelim       | ,
typrelid       | 7566694
typelem        | 0
typarray       | 7566695
typinput       | record_in
typoutput      | record_out
typreceive     | record_recv
typsend        | record_send
typmodin       | -
typmodout      | -
typanalyze     | -
typalign       | d
typstorage     | x
typnotnull     | f
typbasetype    | 0
typtypmod      | -1
typndims       | 0
typcollation   | 0
typdefaultbin  | ¤
typdefault     | ¤
typacl         | ¤
-[ RECORD 2 ]--+------------------------
typname        | _schedules_with_optimal
typnamespace   | 2200
typowner       | 10
typlen         | -1
typbyval       | f
typtype        | b
typcategory    | A
typispreferred | f
typisdefined   | t
typdelim       | ,
typrelid       | 0
typelem        | 7566696
typarray       | 0
typinput       | array_in
typoutput      | array_out
typreceive     | array_recv
typsend        | array_send
typmodin       | -
typmodout      | -
typanalyze     | array_typanalyze
typalign       | d
typstorage     | x
typnotnull     | f
typbasetype    | 0
typtypmod      | -1
typndims       | 0
typcollation   | 0
typdefaultbin  | ¤
typdefault     | ¤
typacl         | ¤

Time: 0.903 ms

So both the array type and the non-array type are present and introspectable. I'm going to flag this as a bug and look into it when I get a chance 👍

@benjie benjie added the bug label Sep 26, 2017
@cookejames
Copy link
Author

Thanks will have a look at it later myself as well

@benjie
Copy link
Member

benjie commented Sep 27, 2017

If you use Node 8.5 then you can stick a debugger statement in the plugin and use node --inspect to see exactly what's going on. This is especially useful if you manage to reproduce it via a postgraphile-core test (these exercise most of the stack currently) - that way you can limit it to running just that one test (via test.only or similar approaches) and figure out exactly what's going on.

@benjie
Copy link
Member

benjie commented Oct 13, 2017

Working on this currently. Almost have it sorted.

@benjie
Copy link
Member

benjie commented Oct 13, 2017

Well... I have it sorted if the table and the columns and the types are all defined in one of the schemas you're exporting. If not it gets a little more... interesting.

Currently looking into adding recursive CTEs into our introspection query 😳

@benjie
Copy link
Member

benjie commented Oct 13, 2017

Work in progress is here. I've not pushed the recursive query yet as it's not working.

#92

@benjie
Copy link
Member

benjie commented Oct 28, 2017

@cookejames Sorry about the delay on this! I think it's fixed now, just waiting for tests to pass.

@qweritos
Copy link

qweritos commented Jun 3, 2018

I have a similar problem, but with subtype of range type:

CREATE TYPE app.foo AS RANGE (subtype = float8, subtype_diff = float8mi);

CREATE FUNCTION app.set_employee_schedule_for_day(array_of_foo app.foo[])
/* ... */

So, arrayOfFoo argument have a type String.

postgraphile: "4.0.0-beta.10"

@benjie
Copy link
Member

benjie commented Jun 3, 2018

Please file as a fresh issue 👍

@benjie benjie added this to the 4.0 milestone Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants