Closed Trellian closed 6 years ago
Hi
Here's the code that generates the select clause. Try debugging that. I have no idea why __typename
appears in the AST node.
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...
whoops sorry I replied on the wrong forum!
http://graphql.org/learn/queries/#meta-fields
It seems that objection-graphql needs to exclude that property.
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.
This is now fixed in master. I'll release a new patch version soon.
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!
Hi @koskimas,
I'm experiencing a problem with __typename appearing in the final query string being sent to the SQL engine, I'm hoping you can help here. Have you seen anything like this before, or could you point me in a direction that might help?
I'm using Apollo Server Express 1.2.0 and Apollo Client 2.0.2.
I have a simple query that works fine in GraphiQL, but not when sent via the client.
and I'm getting an error back as follows:
I've tried raising issues on the GitHub for apollo-client, apollo-server and vue-apollo, but I've not had any response there :(
Any help you can give would be greatly appreciated!
Thank you Adrian