profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/jfrolich/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

jeddeloh/rescript-apollo-client 103

ReScript bindings for the Apollo Client ecosystem

jfrolich/authorize 91

Rule based authorization for Elixir

jfrolich/appCrawler 2

A simple crawler that exhaustively crawles every link on the google app store, and saves the metadata of the applications for analysis.

jfrolich/babel-plugin-styled-object-to-template 1

Babel plugin to transpile object styles to template literal

jfrolich/absinthe 0

The GraphQL toolkit for Elixir

startedreason-in-barcelona/react-rules-of-hooks-ppx

started time in 4 days

issue commentrescript-lang/syntax

weird formatting

Possible dupe of https://github.com/rescript-lang/syntax/issues/259?

bobzhang

comment created time in 5 days

issue commentreasonml-community/graphql-ppx

inconsistent es6/commonJs in Fragments?

By the way, this shouldn't be a problem with webpack5, I have an webpack 5 website deployed that works fine. What is your configuration?

AlexMoutonNoble

comment created time in 8 days

issue commentreasonml-community/graphql-ppx

inconsistent es6/commonJs in Fragments?

If you are using template tags we need an inline require(..) to make it work reliably because ReScript doesn't have support for template tags. You can use templateTagAsFunction which is documented in rescript-apollo-client when you use a bundler that doesn't support require. It's a trade-off, template tags can have some benefits over strings. I would love to have a proper solution for this but I raised possible solutions in the rescript compiler that have not been addressed the past 2 years so I wouldn't hold my breath.

AlexMoutonNoble

comment created time in 10 days

issue commentreasonml-community/graphql-ppx

Can't use ppxCustom on 2nd level of graphQL

Thanks @pzshine!

pzshine

comment created time in 10 days

issue commentreasonml-community/graphql-ppx

Repeated fragment in auto-generated query.

Interesting. I think JS GraphQL clients might do some deduplication. Need to look into this a little deeper.

Zimmi48

comment created time in 10 days

issue commentreasonml-community/graphql-ppx

Repeated fragment in auto-generated query.

This issue didn't happen with lower versions? (because handling of this shouldn't have changed too much I think)

Zimmi48

comment created time in 11 days

issue commentreasonml-community/graphql-ppx

Repeated fragment in auto-generated query.

I think some production users haven't hit this issue because they use the template tag option (default for rescript-apollo-client). What client are you using? I think this should be fixed regardless btw.

Zimmi48

comment created time in 11 days

issue commentreasonml-community/graphql-ppx

Repeated fragment in auto-generated query.

Ah interesting! How would that work in JS?

Zimmi48

comment created time in 11 days

pull request commentrescript-lang/syntax

Unicode support

"bla" will still yield "bla".

Ok, that is nice!

IwanKaramazow

comment created time in 17 days

pull request commentrescript-lang/syntax

Unicode support

Haha no I don't want my source encoded in utf16 at all where did you think I said that? I am just saying that even if string literals are in utf-8 at the file level v8 (or any javascript engine) will convert them to the correct internal runtime representation (which is utf16 for JavaScript), so there is no need to do this "garbling" (let's use this term, probably not the best but you get what I mean).

I am just proposing the following (longer term):

  • Don't run garbling on string at all at a compiler level for "".
  • If we need to keep this around (I would love to see a usecase, so I know better why this feature exists, I think only Hongbo knows this), give it a separate literal like {utf16|...|utf16}.
IwanKaramazow

comment created time in 17 days

issue closedreasonml-community/graphql-ppx

Add INPUT_OBJECT example

Instead of having a bunch of mutations handling a single field update, I thought I'd look at how graphql_ppx_re handles INPUT_OBJECT. The expected type for my input field is pretty gnarly: a closed object with every field being an option. Constructing such an object is not going to be pretty, so I thought I'd see if there were generated helper functions that I overlooked. Unfortunately, I couldn't find any examples of how one would use an INPUT_OBJECT in the documentation. I tried digging through the source and didn't find anything there, either. I think adding an example to the README would be very helpful.

closed time in 17 days

nirvdrum

issue closedreasonml-community/graphql-ppx

Optional string can't be decoded to string field with @ppxCustom

I tried to ask where i could before filling an issue but dont understand what's going on here.

the following example:

module OptionalString = {
 type t = string;
 let parse = opt => switch(opt) {
  | Some(str) => str
  | None => ""
 }

 let serialize = str => {
  if str == "" {
    None 
  } else {
    Some(str)
  }
 }
}

type test {
  image: string,
}

module Query = %graphql(`
  query MyQuery(){
     test @ppxAs({type: "test"}) {
        image @ppxCustom(module: "OptionalString")
     }
  }
`)

lends me this error, and I don't understand why:

 This has type:
    option<'a>

  But somewhere wanted:
    string

It's like the ppxCustom is ignored :/

closed time in 17 days

SkinyMonkey

issue commentreasonml-community/graphql-ppx

Optional string can't be decoded to string field with @ppxCustom

@ppxCustomOpt should fix this in master. I still need to add the documentation.

SkinyMonkey

comment created time in 17 days

issue closedreasonml-community/graphql-ppx

PPX output not respecting bsconfig.json package-specs module setting

I was trying v1 out with snowpack, and reason-apollo-client and noticed the tag was compiling to require("@apollo/client").gql rather than using the import syntax. (snowpack only supports ES6 modules, so my app wouldn't load)

require is hardcoded here: https://github.com/reasonml-community/graphql-ppx/blob/master/src/bucklescript/output_bucklescript_module.re#L219

As a workaround I'm able to use:

[%%raw {|import { gql } from "@apollo/client";|}]

In addition to disabling the template-tag-location andtemplate-tag-import config options.

closed time in 17 days

illusionalsagacity

issue closedreasonml-community/graphql-ppx

Support graphql sdl schemas

Json schemas are not human friendly. having .graphql schemas in repository can be helpful

closed time in 17 days

amiralies

issue commentreasonml-community/graphql-ppx

Support graphql sdl schemas

It's in master now! 🚀

amiralies

comment created time in 17 days

issue closedreasonml-community/graphql-ppx

template tag doesn’t work with Gatsby since beta 12

Gatsby doesn’t seem to like this code:

var query = (require("gatsby").graphql`...`)

It raises this error:

Error: It appears like Gatsby is misconfigured. Gatsby related graphql calls are supposed to only be evaluated at compile time, and then compiled away. Unfortunately, something went wrong and the query was left in the compiled code.

Unless your site has a complex or custom babel/Gatsby configuration this is likely a bug in Gatsby.

Downgrading to beta 11 fixes it.

It seems like Gatsby is extremely strict about how its queries are written in JS, and the require(“gatsby”).graphql style isn’t supported by its compiler.

closed time in 17 days

johnridesabike

issue closedreasonml-community/graphql-ppx

Improve error message when defining fragment on non-existent type

Invalid field names or non-existent query types are caught properly and provide useful errors. However, defining a fragment on NonExistentType will cause quite a cryptic error.

Fatal error: exception Graphql_ppx_base__Option.Option_unwrap_error

  We've found a bug for you!
  /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/src/components/ConversationHeader.res
  
  Error while running external preprocessor
Command line: /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/node_modules/@reasonml-community/graphql-ppx/ppx '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppxbab78dConversationHeader.res' '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppx8c9962ConversationHeader.res'

This looks like a possible unhandled exception in the PPX itself. Perhaps catching this error and translating it to something more useful can help users.

In contrast this is the error for an invalid field:

FAILED: src/screens/CreateChat.ast
File "/Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/src/screens/CreateChat.res", line 8, characters 4-29:
8 |  createPrivateConversation(input: {
        ^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unknown field 'createPrivateConversation' on type Mutation

  We've found a bug for you!
  /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/src/screens/CreateChat.res
  
  Error while running external preprocessor
Command line: /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/node_modules/@reasonml-community/graphql-ppx/ppx '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppx97562fCreateChat.res' '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppxcab177CreateChat.res'

The following error correctly indicates an invalid spread for a missing type.

FAILED: src/components/ConversationTeaser.ast
File "/Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/src/components/ConversationTeaser.res", line 19, characters 19-38:
19 |          ... on MediaMessageContent {
                        ^^^^^^^^^^^^^^^^^^^
Error: Could not find type

  We've found a bug for you!
  /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/src/components/ConversationTeaser.res
  
  Error while running external preprocessor
Command line: /Users/alexander/Projects/drupal_social/html/modules/contrib/social_chat/client/node_modules/@reasonml-community/graphql-ppx/ppx '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppx21e177ConversationTeaser.res' '/var/folders/zd/yqg_23ds2gb1zr65fgy5k2900000gp/T/ppx36f03dConversationTeaser.res'

closed time in 17 days

Kingdutch

issue closedreasonml-community/graphql-ppx

Native clients

Are there any examples of using graphql-ppx with a native client? I'm currently executing queries individually with cohttp, but I'm hoping perhaps someone has already built something a little more sophisticated.

closed time in 17 days

gf3

issue closedreasonml-community/graphql-ppx

custom-fields isn't working from bs-config as expected

using isn't creating custom fields for me. It was working on some other code bases, but I can't get it to work now.

  "graphql": {
    //... other config ...
    "custom-fields": {
      "BigInt": "BigInt",
      "Bytes": "Bytes"
    },
  },

I still need to manually add @ppxCustom(module: "BigInt") to get it to work.

closed time in 17 days

JasoonS

issue closedreasonml-community/graphql-ppx

Syntax errors in @ppxCustom example

The example with recursive definitions from https://beta.graphql-ppx.com/docs/directives#ppxcustom

module UserQuery = [%graphql {|
  query {
    user @ppxCustom(module: "User") {
      id
      name
    }
  }
 |} and User: {
   type t = {
     nameAndId: string
   };
   let parse: UserQuery.t_user => t;
   let serialize: t => UserQuery.t_user;
 } = {
   type t = {
     nameAndId: string
   };
   let parse = user => {
     nameAndId: switch (user.name) {
       None => "Noname" ++ user.id
       Some(name) => name ++ user.id
     }
   };
 }

has syntax errors.

It should at least be

module rec UserQuery = [%graphql
  {|
  query {
    user @ppxCustom(module: "User") {
      id
      name
    }
  }
 |}
]
and User: {
  type t = {nameAndId: string};
  let parse: UserQuery.t_user => t;
  let serialize: t => UserQuery.t_user;
} = {
  type t = {nameAndId: string};
  let parse: UserQuery.t_user => t =
    user => {
      nameAndId:
        switch (user.name) {
        | None => "Noname" ++ user.id
        | Some(name) => name ++ user.id
        },
    };
};

(Beware that this still won't compile due to the missing serialize function and there's not a way to write a sane one)

closed time in 17 days

mbirkegaard

issue closedreasonml-community/graphql-ppx

Option for opaque query types

It would be useful if queries could be given an opaque type instead of string

The motivation is that this would make adding type-safe extensions easier. For example:

module ExtendQuery: (M: GraphQLQuery) => {
  @bs.module("gatsby")
-  external useStaticQuery: string => M.Raw.t = "useStaticQuery"
+  external useStaticQuery: M.queryType => M.Raw.t = "useStaticQuery"
}

You can’t implement an opaque query type in the functor and redefine the query because Gatsby requires query values to be static--they can’t get passed through different functions before use.

closed time in 17 days

johnridesabike

issue commentreasonml-community/graphql-ppx

Option for opaque query types

Ok, I'll close it then. It shouldn't be too hard to implement, perhaps even an "opaque" value to templateTagReturnType?

johnridesabike

comment created time in 17 days

issue closedreasonml-community/graphql-ppx

Two problems with `@ppxCustom`

Problem 1: Parse errors

@ppxCustom as now implemented assumes that parsing can always be done successfully.

Consider a schema where

type Item {
  id: ID!
  name: String!
  hasPriceRange: Boolean!
  price: Int
  minPrice: Int
  maxPrice: Int
}

and our domain knowledge tells us that if hasPriceRange is false, then price should be non-null. If hasPriceRange is true then minPrice and maxPrice should be non-null.

The ideal definitions client side don't work with @ppxCustom because that wants

module Custom = {
  type t = someType;
  let parse: raw => t;
  let serialize: t => raw;
}

and thus doesn't work if parsing could fail. One could do something like;

module Custom = {
  type t = result(someType, string);
  let parse: raw => t;
  let serialize: t => raw;
}

but making serialize accept a result is hardly ideal either.

Proposal

A new directive, e.g. @ppxParser, that accepts something like

module Custom = {
  type t;
  let parse: raw => result(t, 'error);
  let serialize: t => raw;
}

<details> <summary>Full client-side implementation of Item</summary>

type price =
  | Price(int)
  | PriceRange(int, int);

module Item = {
  type t = {
    id: string,
    name: string,
    price,
  };
};

type raw = {
  id: string,
  name: string,
  hasPriceRange: bool,
  price: option(int),
  minPrice: option(int),
  maxPrice: option(int),
};

module ItemDecoder = {
  type t = Item.t;
  let parse: raw => result(t, 'error) =
    ({id, name, hasPriceRange, price, minPrice, maxPrice} as p) =>
      switch (hasPriceRange, price, minPrice, maxPrice) {
      | (false, Some(price), _, _) => Ok({id, name, price: Price(price)})
      | (true, _, Some(minPrice), Some(maxPrice)) =>
        Ok({id, name, price: PriceRange(minPrice, maxPrice)})
      | _ => Error({j|Error parsing price: $p|j})
      };

  let serialize: t => raw =
    ({id, name, price}) => {
      switch (price) {
      | Price(price) => {
          id,
          name,
          hasPriceRange: false,
          price: Some(price),
          minPrice: None,
          maxPrice: None,
        }
      | PriceRange(minPrice, maxPrice) => {
          id,
          name,
          hasPriceRange: true,
          price: None,
          minPrice: Some(minPrice),
          maxPrice: Some(maxPrice),
        }
      };
    };
};

</details>

Problem 2: Serialization isn't always possible or desired

@ppxCustom forces the programmer to implement serialize. That might be fine (if somewhat cumbersome) for small fragments and small queries, but for large top-level queries and more complicated types it will add a lot of extra work. The programmer knows from the application requirements whether they want to be able to serialize. @ppxCustom doesn't know, but still forces them to be able serialize.

I can even imagine cases where it's impossible to write serialize or where, to make it possible, the programmer would have to write the types so that they work for serialization, instead of what is best for the application.

Proposal

Reintroducing the old @bsDecoder directive as @ppxDecoder. It accepts a function that parses the t_whatever type into what the application needs, but which most often would be either t or result(t, 'error).

This was suggested by @jfrolich in #187 as a measure to ease upgrading to 1.0, but I now think that such a directive is generally needed

closed time in 17 days

mbirkegaard

issue commentreasonml-community/graphql-ppx

Two problems with `@ppxCustom`

BTW you don't need to implement a serialize function, this is only necessary if you make use of it. You can just return a dummy value and/or throw an exception.

mbirkegaard

comment created time in 17 days

issue closedreasonml-community/graphql-ppx

Ppx doesn't match `include %graphql(...)` construction

Error:

1 │ include %graphql(

Uninterpreted extension 'graphql'.

closed time in 17 days

alexfedoseev

issue closedreasonml-community/graphql-ppx

verifyArgsAndParse type is undocumented

I'm trying to create a fragment in a module and expose the fragment with a React component in the module file while hiding the other details in the module. However, upon using the fragment the compiler throws the error The value verifyArgsAndParse can't be found in Conversation_View which is true since the definition I copied from the docs does not expose such a function (even though it appears to be required).

I have the following fragment definition

module Conversation_View = %graphql(`
  fragment Conversation_View on Conversation @argumentDefinitions(lastMessages: { type: "Int!" }) {
      id
      ...Conversation_Header
      messages(last: $lastMessages) {
        pageInfo {
          hasPreviousPage
          hasNextPage
          startCursor
          endCursor
        }
        nodes {
          id
          ...Chat_Message
        }
      }
  }
`)

This is used in the following snippet in a different module.

  mutation createPrivateConversation($participant: ID!) {
    createPrivateConversation(input: {
      participant: $participant
    }) {
      errors
      conversation {
        ...Conversation_View @arguments(lastMessages: 20)
      }
    }
  }

closed time in 17 days

Kingdutch

issue closedreasonml-community/graphql-ppx

The tests fail non-deterministically

#=== ERROR while compiling graphql_ppx.1.0.1 ==================================#
# context              2.1.0 | linux/x86_64 | ocaml-base-compiler.4.12.0 | file:///home/opam/opam-repository
# path                 ~/.opam/4.12.0/.opam-switch/build/graphql_ppx.1.0.1
# command              ~/.opam/opam-init/hooks/sandbox.sh build dune runtest -p graphql_ppx -j 31
# exit-code            1
# env-file             ~/.opam/log/graphql_ppx-6724-4dbcde.env
# output-file          ~/.opam/log/graphql_ppx-6724-4dbcde.out
### output ###
#          ppx tests_native/interface.re.pp.ml
# Marshaled file is broken. Doing recovery build...
#          ppx tests_native/list_args.re.pp.ml (exit 1)
# (cd _build/default && .ppx/08407edc227d06689f98d70e968842c7/ppx.exe -o tests_native/list_args.re.pp.ml --impl tests_native/list_args.re.ml --dump-ast)
# Marshaled file is broken. Doing recovery build...
# File "tests_native/list_args.re", line 1:
# Error: I/O error: /home/opam/.opam/4.12.0/.opam-switch/build/graphql_ppx.1.0.1/.graphql_ppx_cache/graphql_schema.json.hash: No such file or directory

closed time in 17 days

kit-ty-kate

push eventreasonml-community/graphql-ppx

Jaap Frolich

commit sha c216bbdabc5576bfc373aeb7dfe0bae358fdd279

simplification

view details

Jaap Frolich

commit sha ebb140459493f3f440f0c34f7ff3f34632fa1dad

Add ppxCustomOpt

view details

push time in 17 days