GithubHelp home page GithubHelp logo

Comments (4)

Gregoirevda avatar Gregoirevda commented on May 22, 2024 1

this is the related issue on graphql_ppx repo: mhallin/graphql_ppx#9

By the time it is fixed, you could also use an alias, which works fine

module GetUser = [%graphql
  {|
    query getUser ($pk: ID!){
      user: User(id: $pk){
          username
      }
    }
|}
];

from reason-apollo.

fakenickels avatar fakenickels commented on May 22, 2024

It is exactly what the error is saying

you are trying to access _User in response with response##_User but what actually exists is response##User.
Also, field names should be camelCase and not PascalCase in GraphQL, I think you'll have a problem there by using User, so update your server schema so you can do this instead for querying:

    query getUser ($pk: ID!){
      user(id: $pk){
          username
      }
    }

from reason-apollo.

dkao1978 avatar dkao1978 commented on May 22, 2024

response##User does not work:

https://bucklescript.github.io/docs/en/object.html#name-mangling

response##_User should be legal.

Though I did give response##User a try and got:

 70 ┆   | Loading => <div>(str("Loading"))</div>
  71 ┆   | Error(error) => (Js.log(error));<div></div>
  72 ┆   | Data(response) => (Js.log(response##User##username));<div></div>
  73 ┆
  74 ┆ }

  Js object ## expect syntax like obj##(paint (a,b))

ninja: error: rebuilding 'build.ninja': subcommand failed
>>>> Finish compiling(exit: 1)

Using lowercase for the schema wouldn't be possible in the short term.

from reason-apollo.

dkao1978 avatar dkao1978 commented on May 22, 2024

Thans @grsabreu.

For posterity, the work around is to use raw:

            switch result {
              | NoData => <div>(str("No Data"))</div>
              | Loading => <div>(str("Loading"))</div>
              | Error(error) => (Js.log(error));<div></div>
              | Data(response) => {
                <div>({let rawUser = [%raw{|result|}];
                let user = rawUser[0]##_User;
                let username = (user[0]##username);
                username
                }
 

from reason-apollo.

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.