Skip to content

GraphQL: Augmented GraphQL Schema (SDL) #5900

Closed
@Moumouls

Description

@Moumouls

Introduce Augmented GraphQL Schema (SDL)

In response of #5894

I would like to propose and discuss the introduction of an SDL system. The main objective will be to help developers improve their GraphQL Server Parse and enable many more features in the future without modifying the Parse Server Core.

Augmented TypeDef file: schema.graphql

const parseGraphQLServer = new ParseGraphQLServer(
  parseServer,
  {
    typeDefs: './schema.graphql'
    graphQLPath: '/graphql',
    playgroundPath: '/playground'
  }
);

@auto: Describe a current Parse class and add auto generation

All other fields will be auto generated

schema.graphql

type Job @auto {
   # Tell to GraphQL that the countries array is a an array of countries
   countries: [Countries]
}

@disableMutations: Disable all mutation or some mutations on the type

schema.graphql

type Job @auto @disableMutations {
   countries: [Countries]
}

OR

type Job @auto @disableMutations(update, delete) {
   countries: [Countries]
}

@disableQueries: Disable all queries or some queries on the type

schema.graphql

type Job @auto @disableQueries {
   countries: [Countries]
}

OR

type Job @auto @disableQueries(get) {
   countries: [Countries]
}

@private: Do not expose a type or a field (in query and input)

schema.graphql

type Job @private
type Job @auto {
   # Tell to GraphQL that the countries array is a an array of countries
   countries: [Countries]
   secretData: String @private
}

@lock: Create/update a Parse.Schema and lock the Class schema

We will create/update the appropriate Parse.Schema. A new way to use Parse.Schema

type Job @lock {
   name: String
   countries: [Countries]
}

@mock: Allow to generate fake datas in dev mode

const parseGraphQLServer = new ParseGraphQLServer(
  parseServer,
  {
    mock: true,
    typeDefs: './schema.graphql'
    graphQLPath: '/graphql',
    playgroundPath: '/playground'
  }
);
type Job @lock {
   name: String @mock(["Developer", "FullStack", "Driver"])
   countries: [Country]
}

type Country @lock {
   name: String @mock(["Developer", "FullStack", "Driver"])
   surface: String @mock(["34 000 000km2"])
}

Allow developers to add description on generated fields

type Job @lock {
  # Here it's a comment displayed on the GraphQL Doc
   name: String
  # Here it's another comment
   countries: [Country]
}

Provide a Mutation loadSchema that allow to send this schema to the server

Need Master Key

type Mutation {
    loadSchema(schema: String): Boolean
}

What do you think about this @davimacedo ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions