mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

Can we use `attributeFields` with graphql SDL? #697

Closed dnafication closed 3 years ago

dnafication commented 3 years ago

Can we use attributeFields with graphql SDL? If yes, how? are there any examples.

To clarify my question further. How to use features of attributeFields like mapping and type transformation without using a syntax like

let trainerType = new GraphQLObjectType({
  name: 'User',
  description: 'A user',
  fields: _.assign(attributeFields(models.User), {
    pokemon: {
      type: new GraphQLList(pokemonType),
      resolve: resolver(models.User.Pokemon)
    }
  })
});

And use following instead

const schema = gql`
  id: String
  pokemon: [Pokemon]
`
mickhansen commented 3 years ago

No, it returns an object. For it to work with gql the template literal would have to accept that format.

dnafication commented 3 years ago

Thanks @mickhansen