profile
viewpoint
Jiří Brabec brabeji Prague, Czech Republic Staying hydrated since 1988

brabeji/angular-formly 0

JavaScript powered forms for AngularJS

brabeji/apollo-link 0

:link: Interface for fetching and modifying control flow of GraphQL requests

brabeji/apollo-link-scalars 0

custom apollo link to allow to parse custom scalars

brabeji/apollo-link-watched-mutation 0

A Link interface for providing default cache updates based on { mutation : query } relationships

brabeji/apollo-tooling 0

:pencil2: Tooling for development and production Apollo workflows

brabeji/axios 0

Promise based HTTP client for the browser and node.js

brabeji/babel-plugin-transform-class-display-name 0

Babel 6 plugin that adds a `displayName` static class property to every ES6 class.

brabeji/bower-installer 0

Tool for installing bower dependencies that won't include entire repos

brabeji/c3-angularjs 0

Angularjs directive for c3.js charts

brabeji/Calendar-PhoneGap-Plugin 0

Create, Change, Delete and Find Events in the native Calendar

issue commentcolinhacks/zod

Request for help: typed Zod combinator with dynamic field name

Follow-up question: is there a reasonably concise way of representing the return type of XmlJsonArray?

const XmlJsonArray = <tag extends string, T>(
  tag: tag,
  schema: z.ZodType<T>
): z.ZodType<{[t in tag]: T | T[]}> => { // doesn't work
  return z.object({}).setKey(tag, z.union([schema, z.array(schema)]));
};

I suspect that I'm running into a hard limitation of TypeScript here, but you'd know better than I.

lilred

comment created time in 4 hours

issue commentgraphql-python/graphene

Union types cannot be resovled. Documentation incomplete

@R1nat-P it does not have anything to do with the union-ed class. instance is the actual data with which the class is called and instance["type"] is just the attribute. You could also do with instance.get("type"). I suggest you to have a closer look at the source code or even set the example up your self locally. Btw, here you can find the stackoverflow article corresponding to it. Hope this helps.

@jmandt ,

Actually was done like was described in official documentation link , therefore was added the part with resolve_type , no luck.

class LoginData(graphene.Union):
    class Meta:
        types = (UsersData, MembershipData)

    @classmethod
    def resolve_type(cls, instance, info):
        @classmethod
        def resolve_type(cls, instance, info):
            if instance["type"] == "UsersData":
                return UsersData
            if instance["type"] == "MembershipData":
                return MembershipData

And getting the following result

Thanks!

jmandt

comment created time in 7 hours

issue commentgraphql-python/graphene

Union types cannot be resovled. Documentation incomplete

@R1nat-P it does not have anything to do with the union-ed class. instance is the actual data with which the class is called and instance["type"] is just the attribute. You could also do with instance.get("type"). I suggest you to have a closer look at the source code or even set the example up your self locally. Btw, here you can find the stackoverflow article corresponding to it. Hope this helps.

jmandt

comment created time in 9 hours

issue commentgraphql-python/graphene

Union types cannot be resovled. Documentation incomplete

@jkimbo this works. Thanks a lot.

How it worked? It returns only 1 class attributes because in resolve_type is return to the 1 class, and not all attributes from union-ed classes.

Thanks!

jmandt

comment created time in 9 hours

startedwhoan/docker-build-with-cache-action

started time in 15 hours

issue commentgraphql-python/graphene

Circular dependencies

@McPo @amaksymov did you manage to solve this?

imranolas

comment created time in 18 hours

issue closedcolinhacks/zod

Parsing process.env safety

I do not speak English natively nor do I consider myself to have a good level. For this reason, I apologize if I make any mistakes and please keep it in mind when reading and interpreting my messages. I'm doing the best I can. Thanks a lot.

Hello, I want to parse process.env

process.env is a Zod.record(Zod.string())

import * as Zod from 'zod';

enum Environments {
  PRODUCTION = 'production',
  DEVELOPMENT = 'development'
}

const EnvironmentVariables = Zod
  .object(
    {
      NODE_ENV: Zod.enum([Environments.DEVELOPMENT, Environments.PRODUCTION]),
      PG_HOST: Zod.string(),
      PG_PORT: Zod.number().int(),
      PG_DATABASE: Zod.string(),
      PG_USERNAME: Zod.string(),
      PG_PASSWORD: Zod.string(),
      /** Add custom environment variables to parse */
    }
  )
  .nonstrict()
  .parse(
    Object.assign(
      {},
      process.env,
      {
        PG_PORT: Number(process.env.PG_PORT),
      }
    )
  );

export const Environment = Object.assign(
  {},
  EnvironmentVariables,
  {
    IS_DEVELOPMENT: EnvironmentVariables.NODE_ENV === Environments.DEVELOPMENT ? true : false,
    IS_PRODUCTION: EnvironmentVariables.NODE_ENV === Environments.PRODUCTION ? true : false,
  },
);

The problem with this, is that [k: string]: any; is any when I want to let it be [k: string]: string;

const EnvironmentVariables: objectUtil.Flatten<{
    NODE_ENV: Environments;
    PG_HOST: string;
    PG_PORT: number;
    PG_DATABASE: string;
    PG_USERNAME: string;
    PG_PASSWORD: string;
} & {
    [k: string]: any; // I want this to be [k: string]: string;
}>

How would you build it? Thanks!

closed time in a day

imsergiobernal

issue commentcolinhacks/zod

Parsing process.env safety

You'll have to use Zod v2, there is a .catchall() method that lets you accomplish this. it isn't possible with Zod 1 unfortunately.

imsergiobernal

comment created time in a day

delete branch graphile/migrate

delete branch : sponsorship/2020_11_25_141546

delete time in a day

push eventgraphile/migrate

Jem

commit sha 3d52a0a63801ae83346b7c200efe7705134821d4

sponsorship: update sponsors 🙏 (#100)

view details

push time in a day

PR merged graphile/migrate

sponsorship: update sponsors 🙏

Sponsorship update for Winter 2020. Thank you to each and everyone of our sponsors, your donations help us to keep working on Graphile Suite 🤩

+17 -6

0 comment

2 changed files

jemgillam

pr closed time in a day

issue commentgraphql-python/graphene

Relay pagination hasPreviousPage bug

For anybody that comes across this ticket, the issue mentioned above https://github.com/graphql-python/graphql-relay-py/issues/12, and there's a PR open with a fix too: https://github.com/graphql-python/graphql-relay-py/pull/14

sebastiandev

comment created time in a day

PR opened graphile/migrate

sponsorship: update sponsors 🙏

Sponsorship update for Winter 2020. Thank you to each and everyone of our sponsors, your donations help us to keep working on Graphile Suite 🤩

+17 -6

0 comment

2 changed files

pr created time in a day

create barnchgraphile/migrate

branch : sponsorship/2020_11_25_141546

created branch time in a day

create barnchgraphile/migrate

branch : sponsorship/2020_11_25_141003

created branch time in a day

create barnchgraphile/migrate

branch : sponsorship/2020_11_25_135237

created branch time in a day

created repositorykandl/redux-saga-race-cancel

created time in 2 days

issue commentcolinhacks/zod

Please use paths instead of array indices for nested schema objects

Here's the workaround for 2 levels of validation:

  } catch (error) {
    const fieldErrors: any = {}
    for (const issue of error.issues) {
      if (issue.path.length > 0) {
        if (issue.path.length === 1) {
          fieldErrors[issue.path[0]] ??= []
          fieldErrors[issue.path[0]].push(issue.message)
        } else {
          fieldErrors[issue.path[0]] ??= {}
          fieldErrors[issue.path[0]][issue.path[1]] ??= []
          fieldErrors[issue.path[0]][issue.path[1]].push(issue.message)
        }
      } else {
        // form error
      }
    }
    return fieldErrors
  }

cybervaldez

comment created time in 2 days

issue commentcolinhacks/zod

Please use paths instead of array indices for nested schema objects

@colinhacks I just ran into this problem. This totally renders the formErrors.fieldErrors useless. I urge you to reconsider this.

If you're using Zod to validate the inputs from a web form, there is a convenient way to "flatten" a ZodError to a format that can be easily displayed to the end user.

I, and it seems the OP, fully expected the same flatten behavior at all levels of the object, not just the first level. The current behavior removes critical information from nested fields (the path to the field). I can't think of any case where that would be desirable 🤔 . Imo if you don't want to change this, then you should remove it all together :)

cybervaldez

comment created time in 2 days

issue openedcolinhacks/zod

Parsing process.env safety

Hello, I want to parse process.env

process.env is a Zod.record(Zod.string())

import * as Zod from 'zod';

enum Environments {
  PRODUCTION = 'production',
  DEVELOPMENT = 'development'
}

const EnvironmentVariables = Zod
  .object(
    {
      NODE_ENV: Zod.enum([Environments.DEVELOPMENT, Environments.PRODUCTION]),
      PG_HOST: Zod.string(),
      PG_PORT: Zod.number().int(),
      PG_DATABASE: Zod.string(),
      PG_USERNAME: Zod.string(),
      PG_PASSWORD: Zod.string(),
      /** Add custom environment variables to parse */
    }
  )
  .nonstrict()
  .parse(
    Object.assign(
      {},
      process.env,
      {
        PG_PORT: Number(process.env.PG_PORT),
      }
    )
  );

export const Environment = Object.assign(
  {},
  EnvironmentVariables,
  {
    IS_DEVELOPMENT: EnvironmentVariables.NODE_ENV === Environments.DEVELOPMENT ? true : false,
    IS_PRODUCTION: EnvironmentVariables.NODE_ENV === Environments.PRODUCTION ? true : false,
  },
);

The problem with this, is that [k: string]: any; is any

const EnvironmentVariables: objectUtil.Flatten<{
    NODE_ENV: Environments;
    PG_HOST: string;
    PG_PORT: number;
    PG_DATABASE: string;
    PG_USERNAME: string;
    PG_PASSWORD: string;
} & {
    [k: string]: any; // I want this to be [k: string]: string;
}>

How would you build it? Thanks!

created time in 2 days

issue closedgraphql-python/graphene

Using interface with Mutation

I want to using interface with Mutation because there is some fields that I have calculate before return to user. I can using interface to avoid rewrite code when return a list ojbects or a single object in Query. But I can't use interface in Mutation to represent data before return to user after create of update it.

So i have to rewrite resolves to create and update.

How can I use interface with Mutation?

closed time in 2 days

tuanden0

issue commentgraphql-python/graphene

Resolver are executing twice

same issue here :/

daveflr

comment created time in 3 days

issue closedcolinhacks/zod

Webpack error when building zod

When building my (typescript) project with webpack (4.41.5) I get:

ERROR in ./node_modules/zod/lib/src/index.js
Module not found: Error: Can't resolve './ZodError' in '/my-project/node_modules/zod/lib/src'
 @ ./node_modules/zod/lib/src/index.js 136:9-30
 @ ./src/zod/zod.ts
 @ ./src/zod/index.ts
 @ ./src/index.ts

I am using zod 1.11.10.

I have made a repo to reproduce the error: https://github.com/mspoulsen/zod-error

Any ideas? Thanks!

closed time in 3 days

mspoulsen

issue commentcolinhacks/zod

Webpack error when building zod

I figured it out. It was my webpack configuration :) https://stackoverflow.com/questions/64966372/module-not-found-error-cant-resolve-types-string-in

mspoulsen

comment created time in 3 days

issue openedgraphql-python/graphene

Using interface with Mutation

I want to using interface with Mutation because there is some fields that I have calculate before return to user. I can using interface to avoid rewrite code when return a list ojbects or a single object in Query. But I can't use interface in Mutation to represent data before return to user after create of update it.

So i have to rewrite resolves to create and update.

How can I use interface with Mutation?

created time in 3 days

issue commentgraphql-python/graphene

Save variables from resolver for later use

I checked it, thank you for telling about dataloaders, I missed this part. But from docs, it seems that it will make some extra operations to database, instead of temporary storaing parameteres from resolve method. Graphene is bloated, and I don't understand why python counterpart of graphql (javascript), should be exactly same as original.

giorgi94

comment created time in 3 days

issue commentgraphql-python/graphene

Save variables from resolver for later use

I believe Dataloaders were invented right for this case.

giorgi94

comment created time in 3 days

issue commentpiglovesyou/graphql-let

import .graphql files is borken in react-scripts@4

In craco.config.js, add the following:

webpack: {
    configure(webpackConfig) {
      const graphqlLoader = {
        test: /\.graphql$/,
        use: [
          { loader: 'babel-loader', options: { presets: ['@babel/preset-typescript', '@babel/preset-react'] } },
          { loader: 'graphql-let/loader' },
        ],
      };

      addBeforeLoader(webpackConfig, loaderByName('file-loader'), graphqlLoader);

      return webpackConfig;
    },
}
redblue9771

comment created time in 3 days

Pull request review commentgraphql-python/graphene

Add support for custom global ID in v2 (Issue #1276)

+from graphql_relay import from_global_id, to_global_id++from ..types import ID, UUID+from ..types.base import BaseType++from typing import Type+++class BaseGlobalIDType:+    """+    Base class that define the required attributes/method for a type.+    """++    graphene_type = ID  # type: Type[BaseType]++    @classmethod+    def resolve_global_id(cls, info, global_id):+        # return _type, _id+        raise NotImplementedError++    @classmethod+    def to_global_id(cls, _type, _id):+        # return _id+        raise NotImplementedError+++class DefaultGlobalIDType(BaseGlobalIDType):+    """+    Default global ID type: base64 encoded version of "<node type name>: <node id>".+    """++    graphene_type = ID++    @classmethod+    def resolve_global_id(cls, info, global_id):+        return from_global_id(global_id)++    @classmethod+    def to_global_id(cls, _type, _id):+        return to_global_id(_type, _id)+++class SimpleGlobalIDType(BaseGlobalIDType):+    """+    Simple global ID type: simply the id of the object.+    To be used carefully as the user is responsible for ensuring that the IDs are indeed global+    (otherwise it could cause request caching issues).+    """++    graphene_type = ID++    @classmethod+    def resolve_global_id(cls, info, global_id):+        _type = info.return_type.graphene_type._meta.name

Actually same comment about interfaces... I don't really see why an interface would be a Node... it's the object type that you would derive from the interface that you would make a node field. Did you have a specific case in mind? Cause I can't write a unit test that makes sense to test that...

tcleonard

comment created time in 4 days

more