gql function export incorrect
Closed this issue · 1 comments
Hi!
I have just check code and found that package exported gql
not from custom function src/gql.js
. it exported in index.js is core.gql
https://github.com/moleculerjs/moleculer-apollo-server/blob/1af1c3769433224cb3b60382d4f8763c6e397bcf/index.js#L26
.
This is why use gql from package return failed compile schema. Can you help fix this.
Thankyou !
The gql
exported from the package is the built-in version from apollo-server-core
. The custom gql
handler which works well with moleculer-apollo-server
is exported as moleculerGql
.
The primary purpose of moleculerGql
is to allow syntax highlighting and code formatting (e.g. prettier) to think they are working with the regular gql
tag, but work with the partial schemas that moleculer-apollo-server
expects. That tooling generally is hardcoded to expect gql
as the name, so if your intent is to use that then you should import is as an alias:
import { moleculerGql as gql } from 'moleculer-apollo-server';
Then you can make variables like:
export const MutationGql = gql`
type Mutation {
welcome(name: String!): String
}
`;
This will then allow for syntax highlighting and formatting. When moleculer-apollo-server
does its schema stitching, it will reformat to drop the type Mutation
(or Query or Subscription) from each individual variable and organize it into one cohesive Query/Mutation/Subscription schema to pass to apollo server.