Code Monkey home page Code Monkey logo

Comments (7)

koskimas avatar koskimas commented on September 3, 2024

Hi

Here's the code that generates the select clause. Try debugging that. I have no idea why __typename appears in the AST node.

from objection-graphql.

Trellian avatar Trellian commented on September 3, 2024

Thanks for the quick response!!! I did try that, using:

graphQLServer.use('/graphql', graphqlExpress({
  schema: graphQlSchema,
  formatParams: (params) => {
    const { query, ...rest } = params;
    const newQuery = query.split('__typename\n').join('')
    console.warn('Query: ' + JSON.stringify(newQuery, null, 2))
    return {
      query: newQuery,
      ...rest
    }
  }
}));

but then it just comes back with a lot of errors complaining about missing __typenames...

from objection-graphql.

Trellian avatar Trellian commented on September 3, 2024

whoops sorry I replied on the wrong forum!

from objection-graphql.

koskimas avatar koskimas commented on September 3, 2024

http://graphql.org/learn/queries/#meta-fields

It seems that objection-graphql needs to exclude that property.

from objection-graphql.

Trellian avatar Trellian commented on September 3, 2024

That did it!

I modified in _filterForSelects() (line 381:

      builder.select(selects.map(it => {
      const col = modelClass.propertyNameToColumnName(it);

        if (jsonSchema.properties[it]) {
          return `${builder.tableRefFor(modelClass)}.${col}`;
        } else {
          return col;
        }
      }));

to

      builder.select(selects.filter(it => {
          return (it !== '__typename');
      }).map(it => {
      const col = modelClass.propertyNameToColumnName(it);

        if (jsonSchema.properties[it]) {
          return `${builder.tableRefFor(modelClass)}.${col}`;
        } else {
          return col;
        }
      }));

Thank you! I just needed a prompt in the right direction.

from objection-graphql.

koskimas avatar koskimas commented on September 3, 2024

This is now fixed in master. I'll release a new patch version soon.

from objection-graphql.

Trellian avatar Trellian commented on September 3, 2024

Ha! you beat me to the PR, and I only took 3 minutes! I've never had an author patch an issue that fast on GitHub before, Kudos to you!

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