Coder Social home page Coder Social logo

Comments (8)

fnimick avatar fnimick commented on June 10, 2024 2

(perhaps a more general solution, in addition to handling citext, would be to allow directives in comments to change the field type as well as the name? that way if we have multiple datatypes that are treated as Opaque by default, we can name them differently and configure a client to map to javascript values in a separate way for each one)

from pg_graphql.

yatendra2001 avatar yatendra2001 commented on June 10, 2024 1

Hey @olirice , I would love to work on this issue. Can you assign this to me??

from pg_graphql.

olirice avatar olirice commented on June 10, 2024

I agree that citext would be better treated as a String. citext is quite common so if it can be supported easily we'll do it

I'd like to hold off on a generic solution for now, but your comment directive idea sounds pretty solid too

from pg_graphql.

yatendra2001 avatar yatendra2001 commented on June 10, 2024

Hi @olirice , so sorry couldn't look up to this issue due to my placement season.

I tried to find citext inside code see but couldn't find it.

I am doing this to trace where exactly unwanted conversion keeps happening.

Can you help?

Also is there any documentation that can help me understand codebase more deeply?

Thanks!!

from pg_graphql.

olirice avatar olirice commented on June 10, 2024

the best place to start to get onboarded would be the resolve function from there you can follow the whole lifecycle of a request from user input to the response.

The basic steps are

from pg_graphql.

olirice avatar olirice commented on June 10, 2024

citext will not be referenced anywhere in the code base. You'd have to identify it on the sql Context and manipulate the GraphQL type that it turns into here

pg_graphql/src/graphql.rs

Lines 1624 to 1659 in 4ac0ca1

fn to_graphql_type(
&self,
max_characters: Option<i32>,
is_set_of: bool,
schema: &Arc<__Schema>,
) -> Option<__Type> {
if is_set_of && !(self.category == TypeCategory::Table) {
// If a function returns a pseudotype with a single column
// e.g. table( id int )
// postgres records that in pg_catalog as returning a setof int
// we don't support pseudo type returns, but this was sneaking through
// because it looks like a concrete type
return None;
}
match self.category {
TypeCategory::Other => {
Some(match self.oid {
20 => __Type::Scalar(Scalar::BigInt), // bigint
16 => __Type::Scalar(Scalar::Boolean), // boolean
1082 => __Type::Scalar(Scalar::Date), // date
1184 => __Type::Scalar(Scalar::Datetime), // timestamp with time zone
1114 => __Type::Scalar(Scalar::Datetime), // timestamp without time zone
701 => __Type::Scalar(Scalar::Float), // double precision
23 => __Type::Scalar(Scalar::Int), // integer
21 => __Type::Scalar(Scalar::Int), // smallint
700 => __Type::Scalar(Scalar::Float), // real
3802 => __Type::Scalar(Scalar::JSON), // jsonb
114 => __Type::Scalar(Scalar::JSON), // json
1083 => __Type::Scalar(Scalar::Time), // time without time zone
2950 => __Type::Scalar(Scalar::UUID), // uuid
1700 => __Type::Scalar(Scalar::BigFloat), // numeric
25 => __Type::Scalar(Scalar::String(None)), // text
// char, bpchar, varchar
18 | 1042 | 1043 => __Type::Scalar(Scalar::String(max_characters)),
_ => __Type::Scalar(Scalar::Opaque),

from pg_graphql.

Marviel avatar Marviel commented on June 10, 2024

Just ran into this issue -- had a custom text-derived type which cannot be filtered down anymore due to Opaque not having an in operator.

@olirice is there any way to denote that a particular user-defined type should be treated as another postgres type during Filtering operations?

In this case, I'd like to tell pg_graphql "hey, you're safe to treat this like you would a text type"

EDIT: this may be what @yatendra2001 is suggesting

EDIT 2: #402 might solve my use case, as mentioned above. Excited for it!

from pg_graphql.

olirice avatar olirice commented on June 10, 2024

is there any way to denote that a particular user-defined type should be treated as another postgres type during Filtering operations?

Not currently, and the domains PR wouldn't resolve that problem. Adding support for citext -> String explicitly #418

from pg_graphql.

Related Issues (20)

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.