Skip to content

How to include cursor and other fields in generated DocumentNode #140

@dolgorukee

Description

@dolgorukee

I have the following code generated:

export const GetEventsDocument = {
  kind: 'Document',
  definitions: [
    {
      kind: 'OperationDefinition',
      operation: 'query',
      name: { kind: 'Name', value: 'GetEvents' },
      variableDefinitions: [
        {
          kind: 'VariableDefinition',
          variable: {
            kind: 'Variable',
            name: { kind: 'Name', value: 'where' },
          },
          type: {
            kind: 'NamedType',
            name: { kind: 'Name', value: 'EventWhereInput' },
          },
        },
      ],
      selectionSet: {
        kind: 'SelectionSet',
        selections: [
          {
            kind: 'Field',
            name: { kind: 'Name', value: 'events' },
            arguments: [
              {
                kind: 'Argument',
                name: { kind: 'Name', value: 'where' },
                value: {
                  kind: 'Variable',
                  name: { kind: 'Name', value: 'where' },
                },
              },
            ],
            selectionSet: {
              kind: 'SelectionSet',
              selections: [
                { kind: 'Field', name: { kind: 'Name', value: 'count' } },
                {
                  kind: 'Field',
                  name: { kind: 'Name', value: 'edges' },
                  selectionSet: {
                    kind: 'SelectionSet',
                    selections: [
                      {
                        kind: 'Field',
                        name: { kind: 'Name', value: 'node' },
                        selectionSet: {
                          kind: 'SelectionSet',
                          selections: [
                            {
                              kind: 'FragmentSpread',
                              name: { kind: 'Name', value: 'EventFields' },
                            },
                          ],
                        },
                      },
                    ],
                  },
                },
              ],
            },
          },
        ],
      },
    },
    ...EventFieldsFragmentDoc.definitions,
  ],
} as unknown as DocumentNode<GetEventsQuery, GetEventsQueryVariables>

export type GetEventsQuery = {
  __typename?: 'Query'
  events: {
    __typename?: 'EventConnection'
    count: number
    edges?: Array<{
      __typename?: 'EventEdge'
      node?: {
        __typename?: 'Event'
        id: string
        title: string
        category: string
        subcategory: string
        place: string
        address: string
        dateAndTime: any
        description: string
      } | null
    } | null> | null
  }
}

export type EventEdge = {
  __typename?: 'EventEdge'
  cursor: Scalars['String']
  node?: Maybe<Event>
}

How do I customise (other than manually) the generated document so it contains, for example, cursor? Preferably in a way that would allow to make requests with the field included and omitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions