gabotechs / graphqxl

GraphQXL is a new language built on top of the GraphQL syntax that extends the original language with some additional features useful for creating scalable and big server side schemas. This repository contains the source code for the GraphQXL compiler.
https://gabotechs.github.io/graphqxl
MIT License
272 stars 8 forks source link

Support empty Query, Mutation, etc. #58

Closed RobertVillalba closed 6 months ago

RobertVillalba commented 6 months ago

I have multiple files with each extending the Query type and a base file with an empty Query.

# base.graphqxl

import "things"

type Query
# things.graphqxl

extend type Query {
  getThings: [Thing!]!
}

...

When running the generator I get

Error: Could not parse GraphQXL spec:

 --> 9:1
  |
9 | type Mutation {}
  | ^---
  |
  = expected type_selection_set, implements, directive, or generic
make: *** [Makefile:16: generated/sensorman.gql] Error 1
gabotechs commented 6 months ago

The recommended way of doing this with GraphQXL would be to instead rely on the already existing composition mechanisms, for example:

# products.graphqxl

type _ProductsQuery {
  product(id: ID!): Product
  productByName(name: String!): Product
  allProducts: [Product!]!
}
# users.graphqxl

type _UsersQuery {
  user(id: ID!): User
  userByName(name: String!): User
  allUsers: [User!]!
}
# main.graphqxl

import 'products'
import 'users'

type Query {
  ..._ProductsQuery
  ..._UsersQuery
}

That way, it's very clear and explicit the order of the fields in the final Query type.

Take a look at this example

RobertVillalba commented 6 months ago

Ah that makes perfect sense thank you!