Giter Site home page Giter Site logo

Comments (9)

dillonkearns avatar dillonkearns commented on July 19, 2024

Hello @nicolasartman, thank you so much for reporting the issue! This should be a pretty simple fix, I'll push something to address it soon.

from elm-graphql.

dillonkearns avatar dillonkearns commented on July 19, 2024

@nicolasartman in the meantime, as a workaround if you simply do a find and replace of API.InputObject.UserFilter.UserFilter => UserFilter within UserFilter.elm that will get you past that compilation error.

I'll get to this soon but hopefully that helps until then!

from elm-graphql.

Frozen666 avatar Frozen666 commented on July 19, 2024

@dillonkearns This workaround fixes the "Cannot find type ..." error message, unfortunately it leads to a recursive type alias (see here: https://github.com/elm-lang/elm-compiler/blob/master/hints/recursive-alias.md).

from elm-graphql.

Frozen666 avatar Frozen666 commented on July 19, 2024

I posted a somewhat related problem concerning the graph.cool APIs on the slack channel already. Those filters will also reference the filters of their relation objects, which in turn reference the starting filter, leading to circular dependencies. This can be seen using the API https://api.graph.cool/simple/v1/cjct1ri2d0twa0114q7ld4xqu, where InputObject.Postfilter imports InputObject.CommentFilter and vice versa

from elm-graphql.

dillonkearns avatar dillonkearns commented on July 19, 2024

@Frozen666 ah, indeed you're correct, with the workaround there are still issues. Thanks for reporting back with that, that saved me some time.

What the code generation needs to do is generate union types (with just a single tag) instead of type aliases. And because of the issue you mention of the circular dependencies, I will need to generate all these types inside of a single file, that way no imports are needed so there is no circular dependency issue. Not too complicated, actually.

from elm-graphql.

dillonkearns avatar dillonkearns commented on July 19, 2024

@Frozen666 @nicolasartman I published a fix for this in npm version 3.0.0! I've got some pretty extensive tests and it's looking good.

I'll leave this open a bit and wait to hear that everything is looking good in case I missed a case in my end-to-end tests. Thanks again to both of you for reporting this issue!

from elm-graphql.

nicolasartman avatar nicolasartman commented on July 19, 2024

from elm-graphql.

nicolasartman avatar nicolasartman commented on July 19, 2024

Sorry for the delay @dillonkearns—I just tested this against my initial API and it's really close I think, but there's one error remaining. For the User object (and only that one it seems), it generates two functions with the same name:

{-|

  - auth0UserId -
  - id -
-}
user : ({ auth0UserId : OptionalArgument String, id : OptionalArgument API.Scalar.Id } -> { auth0UserId : OptionalArgument String, id : OptionalArgument API.Scalar.Id }) -> SelectionSet decodesTo API.Object.User -> Field (Maybe decodesTo) RootQuery
user fillInOptionals object =
    let
        filledInOptionals =
            fillInOptionals { auth0UserId = Absent, id = Absent }

        optionalArgs =
            [ Argument.optional "auth0UserId" filledInOptionals.auth0UserId Encode.string, Argument.optional "id" filledInOptionals.id (\(API.Scalar.Id raw) -> Encode.string raw) ]
                |> List.filterMap identity
    in
        Object.selectionField "User" optionalArgs object (identity >> Decode.maybe)
user : SelectionSet decodesTo API.Object.User -> Field (Maybe decodesTo) RootQuery
user object =
    Object.selectionField "user" [] object (identity >> Decode.maybe)

This, as expected, fails compilation due to top-level identifier ambiguity.

from elm-graphql.

dillonkearns avatar dillonkearns commented on July 19, 2024

Hey @nicolasartman, thank you for reporting back! This is a separate issue so I've created #34 to discuss this problem. Would you mind giving your feedback there? I'll close this one as it appears to be fixed from your account and @Frozen666's.

Thanks again for helping me track this down!

from elm-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.